Developing app, firstly I was about to set assotiations on my applications like this (I have models Test, Key and Answer). Test has many Keys, and Key has one Answer. So in my Test model I set assotiation to Answers like this: has_many :answers, :through => :keys. It seems to be logic: test has many keys which have each one answer, so test has many answers through keys. But after some testing I found out, that Rails doesn't support this logic, because it flashed mass assigned error on key attribute, but If a added to attr_accesible :key_attributes instead of :keys_attributes, it than flashed undefined assotiation. As API documentation says, has_many :through=>... is close to has_many_and_belongs_to_many is kind of some custom version of this. But here is next question. What should I do? Use polymorphic or may be create simple connection between test and answers? What do you think?
on 2013-03-14 13:58
on 2013-03-14 15:08
On Thursday, March 14, 2013 12:57:32 PM UTC, Barry wrote: > attr_accesible :key_attributes instead of :keys_attributes, it than flashed > undefined assotiation. > That sounds like it should work. What did your code look like ? http://api.rubyonrails.org/classes/ActiveRecord/As... has examples of the various supported scenarios. Fred