When you do the following:
form.input :users
And the attribute #users
represents a has_many relationship, then Formtastic generates a select
field with the user #id and #name, but...
How do Formtastic decides that the #name column is what has to be used?
Why not #email, or #login? Is possible to specify it without having to create the collection manually?
Well I found my answer, the source comments for the :select tag says the following:
The way on which Formtastic renders the
value
attribute and content of each<option>
tag is customisable through the:member_label
and:member_value
options. When not provided, we fall back to a list of methods to try on each object such as:to_label
,:name
and:to_s
, which are defined in the configurationscollection_label_methods
andcollection_value_methods
.
https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb