I've just been through 4 pages of similar threads, but nothing quite
satisfying.
What I'm trying to achieve:
<select>
<option value="-1">Please select</option>
<option value="0">ALL</option>
<option value="1">Forum 1</option>
<option value="2">Forum 2</option>
...
<select>
The way I'm currently doing it:
# Plugin
class FakeModel
def initialize(hash)
@hash = hash
end
def id
@hash[:id]
end
def method_missing(meth_id)
@hash[meth_id]
end
end
# Controller
@forums = [
FakeModel.new(:id => -1, :name => 'Please select'),
FakeModel.new(:id => 0, :name => 'ALL')
] + Forum.all(:order => 'name')
# View
<%= collection_select :thread, 'forum_id', @forums, :id, :name %>
Just wondering if there's a more natural (and undocumented) way of doing
it...
--
Posted via http://www.ruby-forum.com/.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.