I am trying to create a user account using Backbone 1.1.2 and Rails 4.2.beta1.
In backbone I am calling:
public create(){
var email:string = $('#create-account-email').val(), password:string = $('#create-account-password').val(), passconf:string = $('#create-account-password-confirm').val();
this.model.set({email: email, password: password, password_confirmation: passconf});
this.model.save(null, {success: this.success, error: this.error});
}
which correctly calls the rails create
method in my webservice with the following request parameters:
{"email":"test@test.com","password":"123456","password_confirmation":"123456"}
It is going through the filter method
def account_params
#breakpoint
params.require(:account).permit(:password, :password_confirmation, :email)
end
but if I place a breakpoint in the above noted spot and inspect the params
object I get:
{"email"=>"test@test.com",
"password"=>"123456",
"password_confirmation"=>"123456",
"controller"=>"accounts",
"action"=>"create",
"account"=>{"email"=>"test@test.com"},
"format"=>"json"}
Which to me looks correct at first glance. But the account creation fails because the password is nil
if inspecting the result of account_params
I only get:
{"email" => "test@test.com")
Why is the password not being included in the account parameter object. I am using all default sacaffolded code with rails and default configuration for Backbone.