On Sat, 2006-09-30 at 11:11 -0600, Dark Ambient wrote:> Is there a way to make pass a variable into a select tag so that the
> prompt would show that value.
>
> In other words if my select was being pulled from a table could I say
> something like this:
>
> @mystate = "New York"
>
> select(:state, :id @states, :prompt => @mystate)
>
> Any possibility ?
----
if your controller does something like...
@my_model.new
@my_model.state = "New York"
then your select already has the default value
If you do a collect for @states, you still have a selection list but
with a default value already entered...
<label for="my_model_state">State:</strong><br/>
<%= options = [[''Select'', '''']] +
@states.collect {
|st| [st.list_value] }
select ''my_model'', ''state'', options
%>
Craig
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---