Has_one :through and update_attributes

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?

throwern wrote:

However, if I try

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

Can anybody explain why that is?

I bet you $10 that u.magazine is nil as well… magazine is not an
attribute but a has_x association (with through)

ilan