Collection_select problem


#1

I have my customer object with title attribute
: @customer.title

Where title is “Mr”,“Mrs”, etc…

In edit/create from i have:
@titles=[“Mr”,“Mrs”,“Miss”]

how do i create a selection box that sets itself to the value of
@customer.title??

This doesn’t work:
<%=collection_select(:customer, :title, @titles)%>

Any help would be appreciated,
THanks


#2

On Sat, 2006-01-28 at 18:30 +0100, Chris wrote:

This doesn’t work:
<%=collection_select(:customer, :title, @titles)%>

Any help would be appreciated,
THanks


Agile book suggests something like this in controller

PAYMENT_TYPES = [
[ “Check”, “check” ],
[ “Credit Card”, “cc” ],
[ “Purchase Order”, “po” ]
].freeze

and something like this in rhtml

<%=
options = [[“Select a payment option”, “”]] + Order::PAYMENT_TYPES
select(“order”, “pay_type”, options)
%>

HTH

Craig