I cant seem to use :through to get the grandchildren objects when the
intermedetiate uses a has_one relationship with the grandchild model.

E.g.

class User < ActiveRecord::Base
  has_many :sentences
  has_many :corrections, :through => :sentences
end


class Sentence < ActiveRecord::Base
  belongs_to :user
  has_one :correction
end


class Correction < ActiveRecord::Base
  belongs_to :sentence
end


I want to do User.corrections

but unfortunately that doesnt work. I get

ActiveRecord::HasManyThroughSourceAssociationMacroError: Invalid source
reflection macro :has_one for has_many :corrections, :through =>
:sentences.  Use :source to specify the source reflection.

but if i remove the has_one and replace it with has_many like so

class Sentence < ActiveRecord::Base
  belongs_to :user
  has_many :corrections #previously has_one
end

then It works. The problem is I dont want to specify has_many because
there will only be one correction for a sentence.

How do i achieve what I want, namely to be able to access all the
corrections for a given user
-- 
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 [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