Navigation Menu

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

ActiveModel::MassAssignmentSecurity::Error in Devise::RegistrationsController#create #1866

Closed
mzaragoza opened this issue May 21, 2012 · 1 comment

Comments

@mzaragoza
Copy link

i am trying to update Divice so my Usermodel has a firstname, lastname, and not just a email and password

so i created a migration

db/migrate/20120521142938_add_username_fistname_lastname_to_users.rb

class AddFistnameLastnameToUsers < ActiveRecord::Migration
def change
add_column :users, :fistname, :string
add_column :users, :lastname, :string
end
end

i also did

rails generate devise:install

To be able to modify the views

This is the new account view
app/views/devise/registrations/new.html.erb

Sign up

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<%= f.label :email %>
<%= f.email_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= f.label :fistname %>
<%= f.text_field :fistname %>
<%= f.label :lastname %>
<%= f.text_field :lastname %>
<%= f.submit "Sign up" %>
<% end %>

<%= render :partial => "devise/shared/links" %>

my Error
When i submit this form i get a error that reads

ActiveModel::MassAssignmentSecurity::Error in Devise::RegistrationsController#create

Can't mass-assign protected attributes: fistname, lastname

Rails.root: /Users/moiseszaragoza/Sites/test_divice
Application Trace | Framework Trace | Full Trace

Request

Parameters:

{"utf8"=>"✓",
"authenticity_token"=>"n2Ee9vXZWFa895MSVzBblkPjcbkCX4A4yvs/EV2qxwI=",
"user"=>{"email"=>"mZaragoza@circletechfl.com",
"password"=>"[FILTERED]",
"password_confirmation"=>"[FILTERED]",
"fistname"=>"Moises",
"lastname"=>"Zaragoza"},
"commit"=>"Sign up"}

Show session dump

Show env dump
Response

Headers:

None

@josevalim
Copy link
Contributor

Please use the mailing list for questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants