On 11 July 2014 23:18, Jan Yo <[email protected]> wrote:
> Colin Law wrote in post #1152183:
>> On 11 July 2014 22:26, Jan Yo <[email protected]> wrote:
>>> Here's the active record relation:
>>>
>>> customer has many memberships
>>> membership_role belongs to membership and role  (link table)
>>>
>>> Is there a more compact, cleaner way to write this?
>>
>> Specify membership has_many roles through membership_role, then you
>> can use membership.roles, which helps a bit.
>>
>> Colin
>
> I was looking for better, more compact code after the for statement.

With has_many through then you can use collect and join on membership.roles

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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv%3DMubBrm4VmNERtcQhUTvc%3DjQN7tx00q54TZhPwvU%2B%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to