On 9 March 2016 at 23:19, John Sanderbeck <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1182071:
>> OK, I did not realise that you wanted to input a numeric value.  The
>> fact that it is an integer rather than, for example, a text string, is
>> irrelevant to the form.  You just need to use f.input.  What you do
>> with that in the controller, of course, is up to you.  You must
>> presumably validate the field accordingly.
>
> The issue is that I can't seem to get the association right. If I try
> and access attendance_count I get an unknown method. I can access it
> using Training.attendees.first.attendance_count, but cannot access it
> using Training.organizations.first.attendance_count

attendance_count is not an attribute of organization, it is an
attribute of attendee so would need something like
Training.organizations.first.attendees.first.attendance_count
An organization has many attendees so for each organization there are
many values of attendance_count.  Which makes me realise that the
table example you posted does not make sense, as each organization
must have multiple rows.  If that is not the case then I do not
understand your associations.

Perhaps you had better tell us exactly what associations you have
setup, in terms of has_many, belongs_to has_many_many through etc.
Tell us what you have declared for each model.

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

Reply via email to