Pie*_*rre 5 forms ruby-on-rails
当我这样做: <%= f.association :user, :collection => User.where(:country_id => 1) %>
我的下拉列表中填充了以下行:
#<User:0x0000010b98d170>
相反,我想显示一封与用户ID相关联的电子邮件.
我还没有找到在使用关联时如何覆盖simple_form的值/内容默认值.
有人可以帮忙吗?
谢谢你,P.
Pet*_*ong 18
虽然github上的页面(https://github.com/plataformatec/simple_form)没有说,但我猜它和示例相同 f.input :age, :collection => 18..60
你可以使用:label_method
和:value_method
:
f.association :user, :collection => User.where(:country_id => 1), :label_method => :name, :value_method => :id
Run Code Online (Sandbox Code Playgroud)
我以前没用过它.请告诉我它是否不起作用.