When I do this: <%= f.association :user, :collection => User.where(:country_id => 1) %>
My dropdown is populated with lines like this:
#<User:0x0000010b98d170>
Instead, I would like to display an email, that is tied to the id of the users.
I have yet to find how to override the value / content defaults of simple_form when using associations.
Can anyone help?
thank you, P.
Although the page on github (https://github.com/plataformatec/simple_form) didn't say, but I guess it's the same as the example f.input :age, :collection => 18..60
You could use :label_method
and :value_method
:
f.association :user, :collection => User.where(:country_id => 1), :label_method => :name, :value_method => :id
I did not use it before. Please tell me if it does not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With