Hi selva,
If you want to set a default value for a select tag using the select_tag
helper, you cant.
Try using select instead,
<%= select :foo, :name, @customer.collect(&:name), {:selected => @
customer.last.name}, {:name => ''name'', :id =>
''name''} %>
On Thu, Feb 3, 2011 at 2:39 PM, selva raj
<ksraj.odc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> what is the syntax for getting the selected value in select_tag
> for example : in model
>
> @customer = Customer.find(:all).map{ |i| i.name}
> redirect_to :action => ''show'',:name=>@customer
>
> i given like this to get the value from database and for view
>
> <%= select_tag (:name, options_for_select(@customer.each{ |name| puts
> name })) %>
>
> <p><label for="name">Name</label><br/>
> <%= text_field ''customer'',''name''
%></p>
>
> <p><label for="place">Place</label><br/>
> <%=text_field
''customer'',''place''%></p>
>
> <p><label
for="balance">Balance</label><br/>
> <%= text_field ''daily'',''balance''
%></p>
>
> <p><label for="todays">Todays
Amount</label><br/>
> <%= text_field ''customer'', ''todays''
%></p>
> i have this code ...
>
> how to solve this please reply me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.