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 })) %>

<%= text_field 'customer','name' %>

<%=text_field 'customer','place'%>

<%= text_field 'daily','balance' %>

Todays Amount
<%= text_field 'customer', 'todays' %>

i have this code ...

how to solve this please reply me

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 [email protected] wrote:

<%= text_field ‘customer’, ‘todays’ %>

For more options, visit this group at