Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user accounts and require them to post new jobs #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'ember-rails'
gem 'ember-source', '1.4.0'
gem 'devise'
gem 'doorkeeper'

group :development, :test do
gem 'rspec-rails', '~> 2.99.0.beta'
Expand All @@ -19,4 +21,7 @@ group :development, :test do
gem 'poltergeist'
gem 'rails-assets-sinonjs'
gem 'rails-assets-ember-mocha-adapter'
gem 'factory_girl_rails'
gem 'forgery'
gem 'pry'
end
30 changes: 30 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GEM
ember-source
execjs
handlebars-source
bcrypt (3.1.7)
builder (3.1.4)
capybara (2.2.1)
mime-types (>= 1.16)
Expand All @@ -42,8 +43,17 @@ GEM
rack-test (>= 0.5.4)
xpath (~> 2.0)
cliver (0.3.2)
coderay (1.1.0)
colorize (0.6.0)
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
doorkeeper (1.0.0)
railties (>= 3.1)
ember-data-source (0.14)
ember-source
ember-rails (0.14.1)
Expand All @@ -59,6 +69,12 @@ GEM
handlebars-source (~> 1.0)
erubis (2.7.0)
execjs (2.0.2)
factory_girl (3.4.2)
activesupport (>= 3.0.0)
factory_girl_rails (3.4.0)
factory_girl (~> 3.4.0)
railties (>= 3.0.0)
forgery (0.5.0)
handlebars-source (1.3.0)
hike (1.2.3)
i18n (0.6.9)
Expand All @@ -78,19 +94,25 @@ GEM
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.8.4)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
orm_adapter (0.5.0)
pg (0.17.1)
poltergeist (1.5.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
Expand Down Expand Up @@ -134,6 +156,7 @@ GEM
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
slop (3.4.7)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -154,6 +177,8 @@ GEM
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)
websocket-driver (0.3.2)
xpath (2.0.0)
nokogiri (~> 1.3)
Expand All @@ -163,13 +188,18 @@ PLATFORMS

DEPENDENCIES
active_model_serializers
devise
doorkeeper
ember-rails
ember-source (= 1.4.0)
factory_girl_rails
forgery
jquery-rails
json_spec
konacha
pg
poltergeist
pry
rails (= 4.0.3)
rails-assets-ember-mocha-adapter
rails-assets-sinonjs
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
class JobsController < ApplicationController
doorkeeper_for :create

respond_to :json

def index
respond_with Job.all
end

def create
@job = Job.create(job_params)

respond_with @job, status: :created
end

private

def job_params
params.require(:job).permit(:title, :description)
end
end
14 changes: 14 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class UsersController < ApplicationController
respond_to :json

def create
@user = User.create(user_params)
respond_with @user
end

private

def user_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
end
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
3 changes: 3 additions & 0 deletions app/serializers/user_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class UserSerializer < ActiveModel::Serializer
attributes :id, :email
end
Loading