R
Ravi Dtv
My 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 grouprow.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 => ','} %>
<%= hidden_field_tag :group_name ,grouprow.group_name %>
<%= submit_tag "Add to group", :class =>
"submit_input_button rounded_corner" %>
<% end %>
</div>
</div>
</td>
</tr>
My controller:
def addfriendtogroups
@f=User.find_by_login(params[:login])
@g=Group.find_by_group_name(params[:group_name])
@addfriend=GroupFriend.create
user_id => current_user.id,
:group_id => @g.id,:friend_id => @f.id)
respond_to do |format|
if @addfriend.save
flash[:notice] = "Friend added to group successfully."
format.html {redirect_to :back}
end
end
end
I get 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
Request
Parameters:
{"group_name"=>"testinggroup2",
"commit"=>"Add to group",
"authenticity_token"=>"MHB8Ys8vccsGwbgnsb9r5T68oqirPpW6YUscfDojZhY=",
"id"=>"testing",
"user"=>{"login"=>"santosh"}}
I need to fetch the id of login (santosh) from users table and id of the
groupname (testinggroup2) from groups and insert the userid, friendid
(id of santosh), groupid (id of testinggroup2) into another table.
Please help. Thanks.
<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 grouprow.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 => ','} %>
<%= hidden_field_tag :group_name ,grouprow.group_name %>
<%= submit_tag "Add to group", :class =>
"submit_input_button rounded_corner" %>
<% end %>
</div>
</div>
</td>
</tr>
My controller:
def addfriendtogroups
@f=User.find_by_login(params[:login])
@g=Group.find_by_group_name(params[:group_name])
@addfriend=GroupFriend.create
:group_id => @g.id,:friend_id => @f.id)
respond_to do |format|
if @addfriend.save
flash[:notice] = "Friend added to group successfully."
format.html {redirect_to :back}
end
end
end
I get 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
Request
Parameters:
{"group_name"=>"testinggroup2",
"commit"=>"Add to group",
"authenticity_token"=>"MHB8Ys8vccsGwbgnsb9r5T68oqirPpW6YUscfDojZhY=",
"id"=>"testing",
"user"=>{"login"=>"santosh"}}
I need to fetch the id of login (santosh) from users table and id of the
groupname (testinggroup2) from groups and insert the userid, friendid
(id of santosh), groupid (id of testinggroup2) into another table.
Please help. Thanks.