I have a user object, and a user_profile object.

In my form I have:

<% form_for(:user, :url => object_url, :html => { :method => :put })
do |f| %>
<% f.fields_for :user_profile do |profile_form| %>

      <div>
      <%= profile_form.label :first_name, t("first_name") %><br />
      <%= profile_form.text_field :first_name %>
      </div>

      <div>
      <%= profile_form.label :last_name, t("last_name") %><br />
      <%= profile_form.text_field :last_name %>
      </div>
<% end %>

...


In my model:

class User < ActiveRecord::Base
  has_one :user_profile
  accepts_nested_attributes_for :user_profile
 
attr_accessible :email, :password, :password_confirmation, :user_profile, 
:user_profile_attributes

And my controller is using the resource_controller plugin.

When I go to do an update, I'm getting:

ActiveRecord::AssociationTypeMismatch (UserProfile(#2197780400)
expected, got HashWithIndifferentAccess(#2159358740))

Here's my data:

Parameters: {"action"=>"update", "_method"=>"put",
"authenticity_token"=>"tkMl1SIlEf2s6wV60cAL/J7hOF2ql614cwWuI4da5lg=",
"id"=>"1", "controller"=>"admin/users", "user"=>{"user_profile"=>
{"last_name"=>"asdf", "first_name"=>"asdf"},
"password_confirmation"=>"[FILTERED]", "role"=>{"admin"=>"1",
"user"=>"1"}, "password"=>"[FILTERED]", "email"=>"[email protected]"}}

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to