Has_one :through doesn't work in Rails 2.2.2


I followed the steps in the following link literally in a new Rails
2.2.2 project

Then I ran it in script/console, getting these error (actually I got
same error in another big rails project before I read that link):

NoMethodError: undefined method update_attributes' for #<Class: 0xb7069980> from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/base.rb:1833:inmethod_missing’
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
active_record/associations/association_collection.rb:370:in send' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/associations/association_collection.rb:370:inmethod_missing’
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
active_record/base.rb:2003:in with_scope' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/associations/association_proxy.rb:202:insend’
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
active_record/associations/association_proxy.rb:202:in with_scope' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/associations/association_collection.rb:366:inmethod_missing’
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
create_through_record' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/associations.rb:1273:inmagazine=’
from (irb):4


I simply copied the code in that link, and in the associated table there
were only needed fields to establish the relations.


On Sun, Jan 4, 2009 at 8:19 PM, Frederick C.


Maybe your defined rails version in environment.rb is not 2.2.2?


I was having the same issue as Clive trying to test the referenced
I was able to get some functionality by using :has_one subscription
rather than :has_many.

I do have a question though.

I can set the through association like this

then user.subscription will = #<Subscription id: 1, user_id: 1,
magazine_id: 1…>

using user.update_attributes(:magazine=>m)
the return is true, but there is no association created. Subscription
remains nil.

Am I wrong in assuming that I should be able to do this?