On 03/10/2009 09:29 AM, Tarscher wrote:
> Hi all,
>
> Groups has_ many users.
>
If one Group has_many Users, then you can access group[1]'s users using
the group's method 'users'.
group = Group.find(1)
users_group_one = group.users
> I have 2 activerecord arrays:
> 1. groups = containing groups with its users.
> 2. users = containing users attending an event.
>
> I start by iterating over the groups. Then I iterate over the users in
> the second array and search for that user in the first array (see
> code). If the user is found, show hime and delete him from the array.
>
> <% groups.each do |group| %>
> <h2><%= group.title %></h2>
> <% users.each do |user| %>
> # I want to search for user in group.users
> # and if present show here and remove the user from
> # group.users (remove from the array not from the database)
> <% end %>
> <% end %>
>
<% groups.each do |group| %>
<% group.users.each do |user| %>
<% end %>
<% end %>
HTH,
davi
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---