I am trying to keep the authentication information generated by Devise
separate from other user related information in "users" and "profiles"
models as follows:
class User < ActiveRecord::Base
has_one :profile
accepts_nested_attributes_for :profile
belongs_to :role
# Include default devise modules. Others available are:
# :token_authenticatable, :lockable and :timeoutable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :active
end
class Profile < ActiveRecord::Base
belongs_to :user
attr_accessible :first_name, :last_name
end
I generated the views and customized the app/views/devise/
registrations/new.html.erb as shown below:
<h2>Sign up</h2>
<%= simple_form_for(resource, :as => resource_name, :url =>
registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.input :password_confirmation, :required => true, :hint =>
"confirmation must match the password" %>
<% fields_for :profile, Profile.new do |pf| %>
<%= pf.text_field :first_name %>
<%= pf.text_field :last_name %>
<% end %>
<%= f.submit "Sign up" %>
<% end %>
<%= render :partial => "devise/shared/links" %>
However, when I try to bring up the form by typing
http://localhost:3000/users/sign_up
I do not see the nested fields for the Profile model at all, neither
on the browser screen nor in the source code as in view page source.
What do I need to do to get this to work?
Thanks.
Bharat