From be83a1726b7cf0a8d1ffb80b957b3da6239cd6d1 Mon Sep 17 00:00:00 2001 From: Thiago Pinto Date: Sat, 13 Sep 2014 19:32:23 -0300 Subject: [PATCH] form_helpers: demonstrating there is also a collection_select method in form builder --- guides/source/form_helpers.md | 6 ++++++ 1 file changed, 6 insertions(+) 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.