On Wed, 24 Oct 2018 at 12:12, John Sanderbeck <bandor...@gmail.com> wrote: > > I'm working on a project that has the following setup > > I have a table called Assessment > > for each assessment there can be different reasons and consequences defined > for that assessment > > then for each assessment the teacher takes multiple data entries over a > period of time > > each data entry can choose multiple reasons and consequences from the ones > defined in the assessment > > So you have assessment > has_many :reasons > accepts_nested_attributes_for :reasons > has_many :consequences > accepts_nested_attributes_for :consequences > has_many :data_entries > accepts_nested_attributes_for :data_entries > > Then reasons > belongs_to :assessment > has_and_belongs_to_many :data_entries
If I understand the problem correctly then you don't need that, you can do has_many data_entries through assessment and in data_entries the same thing the other way round. That is assuming that all the data_entries for a reason are those defined for the assessment it belongs to. Then to get the data_entries for a reason you use reason.assesment.data_entries. Similarly for the other classes. Colin -- 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+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLt9zYe9W6meSZayaBctQPy-i1he__3NGtLXwG%2BHL1zf6Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.