I am using Devise for authentication in a Rails 3 app. I added first_name and last_name columns to the database via db:migrate. The registration form was modified like so:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :first_name %><br />
<%= f.text_field :first_name %></p>
<p><%= f.label :last_name %><br />
<%= f.text_field :last_name %></p>
<p><%= f.label :email %><br />
<%= f.text_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
Validation in the User model:
validates :first_name, :last_name, :email, :password, :password_confirmation, :presence => true
For some reason I am getting "First name can't be blank" and "Last name can't be blank" validation errors. It is interesting to note that these are the two fields added in addition to the stock Devise fields. Does Devise prevent adding other fields to the User model? What other reason could there be?
Thanks.