From: Gregor Panek Date: 2010-05-19T21:03:18+09:00 Subject: Re: passing values from partial to controller yeah that's because you pass only one parameter to the hidden_field_tag so you got this: and your value is still nil, so you have to pass a second parameter to the hidden_field_tag to set the value: <%=hidden_field_tag :group_name, "yourgroupname"%> then you got this in html now you should get with params[:group_name] the value that you set hope this works :) > 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/. >