I have a FinancialDocument#document_type
model attribute. I'd like to let the user select the document type from an HTML select menu populated by an Array of Strings...
doctypes = [ 'Invoice', 'Packing slip', 'Other' ]
For each option, the displayed label and returned value would be identical.
I looked at the select
and collection_select
helpers, but they seem geared toward selecting a child model, not merely a String value. I couldn't discover how to bend them to my purpose.
Here's how I'm trying to do it (I'm using Haml, not Erb)...
form_for(@financial_document) do |f|
- doctypes = [ 'Invoice', 'PS', 'Packing slip', 'Other' ]
= f.collection_select @financial_document, :document_type, \
doctypes, :to_s, :to_s, :include_blank => true
I get this error...
undefined method `merge' for :to_s:Symbol
Is there a different helper that I could use for this? Or a way to use select
or collection_select
?