Ember (0.2.5), Rails (4.2), Ember CLI Rails, Devise, Ember CLI Simple Auth Devise
Action for creating the user model on the 'user/new' controller. Currently the ruby code creates the user in the database however the javascript response is still failing. I haven't been able to find much resources on Ember CLI and Rails with user model creation. Here are the resources I have been using so far (https://adibsaad.com/blog/setting-up-ember-cli-with-a-rails-back-end-and-token-authentication-authorization) and (http://kbarrett.com/blog/2014/03/24/authentication-with-ember-rails.html).
POST http://localhost:3000/users 422 (Unprocessable Entity)
actions: {
createUser: function() {
var user = this.store.createRecord('user', {
name: this.get('name'),
gradePoints: this.get('gradePoints'),
gradeUnits: this.get('gradeUnits'),
email: this.get('email'),
password: this.get('password')
});
var self = this;
user.save().then(function() {
self.get('session').authenticate('ember-simple-auth-authenticator:devise', {
identification: user.get('email'),
password: user.get('password')
}).then((function() {
self.transitionToRoute('dashboard');
}));
}, function() {
alert('Failed to register user.');
});
}
}
Ruby Code
class UsersController < ApplicationController
respond_to :json
def create
user = User.new(user_params)
binding.pry
if user.save
render json: user, status: :created
else
respond_with user
end
end
private
def user_params
params.require(:user).permit(:name, :email, :gradePoints, :gradeUnits, :password, :password_confirmation)
end
end
Let me know if I need to provide anything else.
Started POST "/users" for ::1 at 2015-05-25 09:36:54 -0700
Processing by UsersController#create as JSON
Parameters: {"user"=>{"email"=>"[email protected]", "name"=>"Arin", "gradePoints"=>217.665, "gradeUnits"=>63, "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}
(0.2ms) BEGIN
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
(0.1ms) ROLLBACK
Completed 422 Unprocessable Entity in 118ms (Views: 0.9ms | ActiveRecord: 0.7ms)