I read a lot of related posts, but can't find why it doesn't work for me. I still have βI canβt assign protected attributes: profilesβ ... What am I doing wrong?
I have a user model and a related one-to-one profile model. Here's the user model (simplified)
class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation, :profile_attributes, :profile_id has_secure_password has_one :profile accepts_nested_attributes_for :profile end
Profile model
class Profile < ActiveRecord::Base attr_accessible :bio, :dob, :firstname, :gender, :lastname, :user_id belongs_to :user end
my user controller
def new @user = User.new respond_to do |format| format.html
If this can help, both users and the profile have been tinted.
I also tried using ': profiles_attributes' instead of 'profile_attributes' in User attr_accessible, same problem ...
also tried "@ user.profiles.build" instead of "@ user.build_profile" in the user controller ... same result ...
Any help with some explanation would be great (I'm noob on the rails, so forgive me)
EDIT The simple form I use
<%= simple_form_for(@user) do |f| %> <%= f.error_notification %> <%= f.simple_fields_for :profiles do |p| %> <div class="nested-form-inputs"> <%= p.input :lastname %> <%= p.input :firstname %> </div> <% end %> <div class="form-inputs"> <%= f.input :email %> <%= f.input :password %> <%= f.input :password_confirmation %> </div> <div class="form-actions"> <%= f.button :submit %> </div> <% end %>
Greetings