I have the following piece of code in an app:
@states = LookupValue.find(:all,
:conditions => ['record_type = ?',
‘STATE’],
:order => “char_value_1”).map {|u|
[u.char_value_1, u.id] }
This builds a list of codes and descriptions from a common values
table. The values are used in a “select” on a page. The page works
fine, however, we would like to have an empty inserted at the
beginning of the list to force the user to actually select an item
from the list. Any suggestions how I can insert an empty/blank code/
description to @states ??
Thanks,
rails.impaired
rails.impaired wrote:
I have the following piece of code in an app:
@states = LookupValue.find(:all,
:conditions => ['record_type = ?',
‘STATE’],
:order => “char_value_1”).map {|u|
[u.char_value_1, u.id] }
This builds a list of codes and descriptions from a common values
table. The values are used in a “select” on a page. The page works
fine, however, we would like to have an empty inserted at the
beginning of the list to force the user to actually select an item
from the list. Any suggestions how I can insert an empty/blank code/
description to @states ??
Thanks,
rails.impaired
select(“something”, “something_id”, @states, { :include_blank => true })
read more here