On Thursday, March 14, 2013 12:57:32 PM UTC, Barry
wrote:>
> 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.
>
That sounds like it should work. What did your code look like ?
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
has examples of the various supported scenarios.
Fred
> 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?
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/iVYDjijuZmsJ.
For more options, visit https://groups.google.com/groups/opt_out.