I have a user who has a list of friends on displayed on his webpage.
He can add each friend to a group like, Family or Friends.
To implement this , I have the select_tag /form_tag block inside a
loop in my view as shown:
<% @user.friend.each do |friend| %>
<%= form_tag({:controller => ‘friendship’, :action =>
‘addgroup’, :id => friend.screen_name} ) %>
<%= select_tag( “groupname”, options_for_select(%w{ Family
Friends })) %>
<%= submit_tag “Add #{friend.name}” %>
<% end %>
<% end %>
On submit the controller friendship/addgroup is invoked with
parameter :id => friend.screen_name. I also access params[:groupname]
in addgroup.
My problem is that even though this is in a loop, when I click on “Add
friend” and submit the form the :id => screen_name is always the
first friend for the user in the database.
What am I doing wrong ?
Thanks