R
Ravi Dtv
I am trying to pass login and group_name from partial to controller, but
I dont get the values.
I see the following error:
RuntimeError in UsersController#addfriendtogroups
Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id
I tried in the console, where I get the result. But, in application I
cannot pass the values.
html page
-----------------
<% @groups.each do |user| %>
<%= render
artial => 'users/grouprow', :locals => {:user
=> user}%>
<% end %>
Partial
-----------
<tr>
<td class="people_profile">
<div class="clear_float_effect">
<div class="profile_block">
<p>
<span title="Click to edit" id="edit_location">
<%= link_to user.group_name %>
</span>
<a href="#" class="short_description_text btn"
id="edit_group_link"> <%= custom_button('Change') %> </a>
</p>
</div>
<div>
<% form_tag
controller => "users" , :action => "addfriendtogroups")
do %>
Add friend:
<%= text_field_with_auto_complete :user, 'login', {:size =>
20}, {:tokens => ','} %>
<%= submit_tag "Add to group", :class =>
"submit_input_button rounded_corner" %>
<% end %>
</div>
</div>
</td>
</tr>
Controller
----------------
def addfriendtogroups
@f=User.find_by_login(params[:login]).id
@g=Group.find_by_group_name(params[:group_name]).id
@addfriend=GroupFriend.create
user_id => current_user.id ,
:group_id => @g,:friend_id => @f)
respond_to do |format|
if @addfriend.save
flash[:notice] = "Friend added to group successfully."
format.html {redirect_to :back}
end
end
end
I dont get the values.
I see the following error:
RuntimeError in UsersController#addfriendtogroups
Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id
I tried in the console, where I get the result. But, in application I
cannot pass the values.
html page
-----------------
<% @groups.each do |user| %>
<%= render
=> user}%>
<% end %>
Partial
-----------
<tr>
<td class="people_profile">
<div class="clear_float_effect">
<div class="profile_block">
<p>
<span title="Click to edit" id="edit_location">
<%= link_to user.group_name %>
</span>
<a href="#" class="short_description_text btn"
id="edit_group_link"> <%= custom_button('Change') %> </a>
</p>
</div>
<div>
<% form_tag
do %>
Add friend:
<%= text_field_with_auto_complete :user, 'login', {:size =>
20}, {:tokens => ','} %>
<%= submit_tag "Add to group", :class =>
"submit_input_button rounded_corner" %>
<% end %>
</div>
</div>
</td>
</tr>
Controller
----------------
def addfriendtogroups
@f=User.find_by_login(params[:login]).id
@g=Group.find_by_group_name(params[:group_name]).id
@addfriend=GroupFriend.create
:group_id => @g,:friend_id => @f)
respond_to do |format|
if @addfriend.save
flash[:notice] = "Friend added to group successfully."
format.html {redirect_to :back}
end
end
end