开发者

Rails simple_form association help with option tag

In my form I have:

<%= f.association :virksomhed, :collectio开发者_开发百科n => Virksomhed.all(:order => 'navn'), :prompt => "Vælg virksomhed" %> 

In view I have this:

Rails simple_form association help with option tag

I instead of the object I want to display the name (navn on danish) of the companyies.


I believe you're looking for the :label_method option:

<%= f.association :virksomhed, :collection => Virksomhed.all(:order => 'navn'), :prompt => "Vælg virksomhed", :label_method=>:navn %> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜