Topic: Divice Update [SOLVED]

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

<h2>Sign up</h2>

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

  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

  <div><%= f.label :fistname %><br />
  <%= f.text_field :fistname %></div>

  <div><%= f.label :lastname %><br />
  <%= f.text_field :lastname %></div>

  <div><%= f.submit "Sign up" %></div>
<% 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: username, 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

Last edited by moiseszaragoza (2012-05-21 12:05:49)

Re: Divice Update [SOLVED]

I was able to update this by adding firstname & lastname to the users model

Thanks