I'm wondering about the difference between update_attributes(:method)
and class.method=

I have setup an example similar to the one here:
http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-one-through

The main difference is that I use a has_one instead of has_many for my
has_one :through relationship (has_one :subscription)

the following code works:

u = User.create(:name=>"test_user")
=> #<User id: 10001, name: "test_user", created_at: "2009-01-16
14:59:45", updated_at: "2009-01-16 14:59:45">

u.magazine = Magazine.create(:name => "mag")
=> #<Magazine id: 10005, name: "mag", created_at: "2009-01-16
14:59:48", updated_at: "2009-01-16 14:59:48">

u.subscription
=> #<Subscription id: 10001, user_id: 10001, magazine_id: 10005,
created_at: "2009-01-16 14:59:48", updated_at: "2009-01-16 14:59:48">


However,  if I try

u.update_attributes(:magazine=>m)
the return is true yet u.subscription is nil

Can anybody explain why that is?




--~--~---------~--~----~------------~-------~--~----~
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