There''s always 8 ways to skin a cat in RoR, but here''s one...
<%= select("object", "method", Item.find_all.collect {
|i| [ i.name,
i.id ] }) %>
The "object" and "method" will be advised by how you wish to
use the
field once you get it back to the controller/action of the form. For
instance,
<%= select("order_line", "item_id", Item.find_all.collect
{ |i| [
i.name, i.id ] }) %>
...will populate params[:order_line][''item_id''] with the id of
the item
you choose in the list.
c.
August wrote:> Hi everyone,
> I have in a DB table item id''s (ints) and what i''d like
to do is
> populate a select box (in another separate ruby app) with the
> corresponding name of each item. What''s the best way to go about
that -
> this isn''t working too well for
>
me(http://www.protoscript.net/article/4/ruby-on-rails--filling-select-boxes)
--
Posted via http://www.ruby-forum.com/.