i'm writing piece of app allows upload photos , assign them bus. want drop-down menu name values. buses can either enabled or not. i'd restrict list enabled buses. i'm not sure how in form drop down menu.
this know how do:
<% bus.find(:all, :conditions => {:is_enabled => 1).each |bus| %> <%= bus.name %> <% end %>
but don't know how put code in form without breaking in variety of different ways, , don't know other way these names. app uses older version (rails 2.3.15).
this best guess on how it:
<% form_for @bus_image, :html => { :multipart => true } |f| -%> <%= f.error_messages %> <div class="field"> <%= f.label :name %><br /> <% bus.find(:all, :conditions => {:is_enabled => 1}).each |bus| %> <%= select(bus.name) %> <% end %> <div> <% end -%>
... gives me wrong number of arguments (1 3)
.
thanks, let me know if need/want more information.
use :
f.select(:bus_id, bus.find(:all, :conditions => {:is_enabled => 1}).map{|b| [ b.name, b.id ] }, {:include_blank => true })
in place of :
<% bus.find(:all, :conditions => {:is_enabled => 1}).each |bus| %> <%= select(bus.name) %> <% end %>
hope help.
Comments
Post a Comment