Wednesday, June 20, 2012

[Rails] Re: Re: Associations join

Colin Law wrote in post #1065311:
> On 20 June 2012 09:32, Timen E. <lists@ruby-forum.com> wrote:
>> card from my cardlevel array, but i can't seem to access it like this. I
>> can however loop it in a seperate each, but i don't want that obviously.
>
> You have not explained well what you are trying to do, but possibly
> you want to loop through the cardlevels instead of the cards, then for
> each cardlevel you can obtain the card aswell as the other data, so
> something like
>
> <% @user.cardlevels.each do |cl| %>
> <%= cl.card.name %><br>
> <%= cl.other_data %>
> <% end %>
>
> You might need to check for cl.card nil though.
>
> Colin

You're my savior, thanks alot! It's more the train of thought that needs
correcting than my code i guess.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate