Hello, i tried to create radio button accordingly.. but i am gettin errors..here is the code.. for radio button
<% form_for(@user) do |f| -%> <p> <%= f.radio_button("user","approved","yes")%> </p> <% end -%> I am getting error as undefined method `merge' for "yes":String Extracted source (around line *#28*): 25: <b> APPROVAL </b><br /> 26: <% form_for(@user) do |f| -%> 27: <p> 28: <%= f.radio_button("user","approved","yes")%> 29: </p> 30: <% end -%> 31: <%= link_to '<b>Approve</b>', users_path %> Plz help :) :) On Thu, Jul 8, 2010 at 8:46 PM, Deepak Kamath <dk87...@gmail.com> wrote: > Thank You Marius, for your help. [?] > > > On Thu, Jul 8, 2010 at 4:32 PM, Marius Mårnes Mathiesen < > marius.mathie...@gmail.com> wrote: > >> On Thu, Jul 8, 2010 at 11:23 AM, Deepak Kamath <dk87...@gmail.com>wrote: >> >>> I am using radio button in my form .... how can i store the value of >>> radio button in database .. my code is >>> >>> >>> <%= radio_button_tag(:users,"yes") %> >>> <%=label_tag(:approved,"YES") %> <br /> >>> >>> Radio button ll be generated ..but how to store yes into 'appoved' field >>> in database >>> >> >> Deepak, >> The value of this radio button will be submitted to the server as - iirc - >> users[yes]. So in the controller, this value would be accessible as >> params[:users][:yes]. The usual way of creating and handling forms in Rails >> is to expose instance variables from an ActiveRecord object through a form >> builder object, like this: >> >> <% form_for(@user) do |f| -%> >> <%= f.text_field :email -%> >> <% end -%> >> >> This will create a form tag with the relevant action and method, along >> with a single field referencing the user's email address. When you submit >> this form to the controller, the entire set of variables for the user can be >> referenced as params[:user], and the single value as params[:user][:email]. >> Since these are all instance variables, Rails lets you set values in the >> object directly, ie: >> >> @user.update_attributes(params[:user]) >> @user = User.create(params[:user]) >> >> The xxx_button_tag and similar are very rarely used in Rails these days. >> >> There's some decent documentation on Rails' form helpers here: >> http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html >> >> Cheers, >> - Marius >> >> -- >> To post to this group, send email to gitorious@googlegroups.com >> To unsubscribe from this group, send email to >> gitorious+unsubscr...@googlegroups.com<gitorious%2bunsubscr...@googlegroups.com> >> > > -- To post to this group, send email to gitorious@googlegroups.com To unsubscribe from this group, send email to gitorious+unsubscr...@googlegroups.com
<<331.gif>>