From: Gregor Panek Date: 2010-05-19T20:29:24+09:00 Subject: Re: passing values from partial to controller --Apple-Mail-2--391387331 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, I think your problem is this line: @g=3DGroup.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 =3D> "users" , :action =3D> = "addfriendtogroups") do %> Add friend: <%=3D text_field_with_auto_complete :user, 'login', {:size =3D> 20}, {:tokens =3D> ','} %> <%=3D submit_tag "Add to group", :class =3D> "submit_input_button rounded_corner" %> <% end %> So pass your :group_name trough a hidden field to your controller hidden_field=20 Am 19.05.2010 um 13:07 schrieb Ravi Dtv: > Gregor Panek wrote: >> hi, >>=20 >> pass your parameters to your partial like this: >> <%=3Drender :partial =3D> 'users/grouprow' ,:collection =3D> = @groups%> >>=20 >>=20 >> and when you want to call the parameters in your partial, you have to=20= >> call it by the name of your partial so it will be something like = this: >>=20 >> grouprow.id >> grouprow.name >>=20 >>=20 >> Greg >=20 > Thanks Greg for the reply. >=20 > I can display the values in my partial. > My problem is I need to pass the values from my partial to the=20 > controller. >=20 > I have a link, textbox and button in my partial. > The link holds groupname. the textbox holds friendname. > When I click Add button, the friend in the textbox should be added to=20= > the group and insert into the table. > My def in controller >=20 > Controller > ---------------- >=20 > def addfriendtogroups > @f=3DUser.find_by_login(params[:login]).id > @g=3DGroup.find_by_group_name(params[:group_name]).id >=20 > @addfriend=3DGroupFriend.create(:user_id =3D> current_user.id , > :group_id =3D> @g,:friend_id =3D> @f) >=20 > respond_to do |format| >=20 > if @addfriend.save >=20 > flash[:notice] =3D "Friend added to group successfully." > format.html {redirect_to :back} >=20 > end >=20 > end > end >=20 >=20 > Please correct the def. >=20 > Thanks. > --=20 > Posted via http://www.ruby-forum.com/. >=20 --Apple-Mail-2--391387331--