Option for select

One thing I haven’t figured out or found an answer to is if I create a
select tag from a database table, how can I have an option for “Please
select” or “choose” or whatever -
I know i can do something like :include_blank => true. That works
fine. I came across an option like :include_blank_text => ‘something’,
but that didn’t work.

Anyone know how to do it ?

Stuart


On 9/19/06, Dark A. [email protected] wrote:

One thing I haven’t figured out or found an answer to is if I create a
select tag from a database table, how can I have an option for “Please
select” or “choose” or whatever -
I know i can do something like :include_blank => true. That works
fine. I came across an option like :include_blank_text => ‘something’,
but that didn’t work.

Anyone know how to do it ?

Add that option manually.

@options = [[‘Select from list’, ‘’]] + Product.find(:all,
…).map{|p| p.name, p.id}

options_for_select(@options, …)


Rule Of Robustness: Robustness is the child of transparency and
simplicity.

I can’t seem to make this work -

This is what I have currently -
State

<% @states = State.find(:all, :order => “name”).map {|s| [s.name, s.id]}
%>
<%= f.select(“state” , @states, “include_text” => ‘please’ ) %>

Adding in the options seems to throw some parsing errors.

Stuart

On 9/19/06, Michael C. [email protected] wrote:

Anyone know how to do it ?
simplicity.


<% @states = [[‘Please’, ‘’ ]] + State.find(:all, :order => “name”).map
{|s| [s.name, s.id]} %>
<%= f.select(“state” , @states ) %>

Okay, working now as;
State

<% @states = State.find(:all, :order => “name”).map {|s| [s.name, s.id]} %>
<%= f.select(“state” , [[‘Please Select’, ‘’]] + @states ) %>

Does anyone know what the ‘prompt’ option is in a select ? I came
across mention of this in this patch message -
http://dev.rubyonrails.org/ticket/3858
Haven’t found anything on it though.

Stuart

On 9/19/06, Dark A. [email protected] wrote:

but that didn’t work.

Rule Of Robustness: Robustness is the child of transparency and
simplicity.


http://en.wikipedia.org/wiki/Dark_ambient


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs