Reputation: 3333
I have models:
class Materialtitle < ActiveRecord::Base
has_many :edocs
end
class Edoc < ActiveRecord::Base
belongs_to :materialtitles
end
I may do Materialtitle.find(2).edocs
.
I would like to do something like Edoc.find(10).materialtitles
. But It returns nil.
Could someone help me?
Upvotes: 0
Views: 1218
Reputation: 2679
If it is many-to-one then it should be belongs_to :materialtitle
(singular) and your DSL should look like:
Edoc.includes(:materialtitle).find(10).materialtitle
Upvotes: 1