form_helpers: demonstrating there is also a collection_select method in form builder

This commit is contained in:
Thiago Pinto 2014-09-13 19:32:23 -03:00
parent 29366cdad7
commit be83a1726b
1 changed files with 6 additions and 0 deletions

View File

@ -506,6 +506,12 @@ As the name implies, this only generates option tags. To generate a working sele
<%= collection_select(:person, :city_id, City.all, :id, :name) %>
```
As with other helpers, if you were to use the collection_select helper on a form builder scoped to the @person object, the syntax would be:
```erb
<%= f.collection_select(:city_id, City.all, :id, :name) %>
```
To recap, `options_from_collection_for_select` is to `collection_select` what `options_for_select` is to `select`.
NOTE: Pairs passed to `options_for_select` should have the name first and the id second, however with `options_from_collection_for_select` the first argument is the value method and the second the text method.