ruby - rails simple_form_for association select text -



ruby - rails simple_form_for association select text -

i using rails 3.0, ruby 1.9.2 , plataformatec simple_form gem.

the code below renders select box consumer names. want show select box consumer locations instead. how do that?

view code:

<%= simple_form_for @request |f| %> <%= f.association :consumer, :collection => consumer.all, :prompt => "choose location" %> <%= f.button :submit %> <% end %>

model code:

consumer < activerecord::base attr_accessor :name, :location end

you via label_method

<%= f.association :consumer, :collection => consumer.all, :prompt => "choose location", :label_method=>:location %>

ruby-on-rails ruby simple-form

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -