Hi, Im having an issue with accepts_nested_attributes_for for a has_one relationship. I have posted the code below and the parameters sent to the create but this is not saving the user_detail association record.
Ive tried various solutions from the links below but cant get this to work. Can anyone suggest what im doing wrong? class User < ActiveRecord::Base has_one :user_detail, :dependent => :destroy accepts_nested_attributes_for :user_detail attr_accessible :first_name, :user_detail_attributes end def new @user = User.new #...@user.build_user_detail end - form_for([:members, @user]) do |user_form| = user_form.label 'first_name', 'First Name' = user_form.text_field :first_name -...@user.build_user_detail unless @user.user_detail -user_form.fields_for :user_detail do |ud_form| %li = ud_form.label 'website_url' = ud_form.text_field :website_url "user"=>{"user_detail_attributes"=>{"website_url"=>"www.bbc.co.uk"}, "commit"=>"Sign up"} http://www.pixellatedvisions.com/2009/03/18/rails-2-3-nested-model-forms-and-nil-new-record http://stackoverflow.com/questions/742536/rails-nested-object-form-attributes-problem http://guides.rubyonrails.org/2_3_release_notes.html#nested-object-forms http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes I also tried replacing -user_form.fields_for :user_detail do |ud_form| with -user_form.fields_for @user.user_detail do |ud_form| but then i got UserDetail(#48943070) expected, got HashWithIndifferentAccess(#23663900) JB -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---