On Wed, 24 Oct 2018 at 23:21, John Sanderbeck <bandor...@gmail.com> wrote:

> One question though...   For a through association, I have to have a join
> table for the association.
>

No, if you say
Reason has_many :data_entries, :through: :assessment
then since you already have reason belongs_to assessment so if you have a
Reason in @reason then you can say
@assessment = @reason.assessment.
Also you already have assessment has_many data_entries so you can say
@data_entries = @assessment.data_entries
Therefore you can get direct from a reason to the associated data_entries
using
@data_entries = @reason.assessment.data_entries
No need for an additional join table.

Have a look at the Rails Guide on Associations for more detail.
You might also like to work through the tutorial at railstutorial.org
(which is free to use online) which should cover this and all the other
basics of Rails.

Colin

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%3D0gLt%2BJBvi%3DTXy_D5_eomavGyGaKFjLzBcaTv0v9rkdEHofg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to