aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Pinto <tapgyn@gmail.com>2014-09-13 19:32:23 -0300
committerThiago Pinto <tapgyn@gmail.com>2014-09-13 19:32:23 -0300
commitbe83a1726b7cf0a8d1ffb80b957b3da6239cd6d1 (patch)
treea80025a5cd1c886d270feb62aa8b78dbb1fa9023
parent29366cdad7e11cb582602ff8f4342108d66bf235 (diff)
downloadrails-be83a1726b7cf0a8d1ffb80b957b3da6239cd6d1.tar.gz
rails-be83a1726b7cf0a8d1ffb80b957b3da6239cd6d1.tar.bz2
rails-be83a1726b7cf0a8d1ffb80b957b3da6239cd6d1.zip
form_helpers: demonstrating there is also a collection_select method in form builder
-rw-r--r--guides/source/form_helpers.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md
index 9ced77dfd7..16fa23c129 100644
--- a/guides/source/form_helpers.md
+++ b/guides/source/form_helpers.md
@@ -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.