From: Ravi Dtv Date: 2010-05-19T20:42:26+09:00 Subject: Re: passing values from partial to controller Gregor Panek wrote: > Hi, > > I think your problem is this line: > @g=Group.find_by_group_name(params[:group_name]).id > > you want to pass the params :group_name which are nil because in your > form you don't pass the :group_name to your controller: > > <% 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 %> > > So pass your :group_name trough a hidden field to your controller > > hidden_field > > > Am 19.05.2010 um 13:07 schrieb Ravi Dtv: I tried with a hidden field <% form_tag (:controller => "users" , :action => "addfriendtogroups") do %> Add friend: <%= text_field_with_auto_complete :user, 'login', {:size => 20}, {:tokens => ','} %> <%= hidden_field_tag :group_name %> <%= submit_tag "Add to group", :class => "submit_input_button rounded_corner" %> <% end %> but it still a nil value. The 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"=>"", "commit"=>"Add to group", "authenticity_token"=>"MHB8Ys8vccsGwbgnsb9r5T68oqirPpW6YUscfDojZhY=", "id"=>"testing", "user"=>{"login"=>"santosh"}} where 'testing' is current user login, santosh is friend, and my group_name is passing null value. -- Posted via http://www.ruby-forum.com/.