diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2009-01-25 12:36:56 +0000 |
---|---|---|
committer | Frederick Cheung <frederick.cheung@gmail.com> | 2009-01-25 12:36:56 +0000 |
commit | 14dd6c4d2f978d743269cf1096f0ad551a32d240 (patch) | |
tree | e52c53d41e14e37d793f7fa4d780b230f7259040 /railties/doc/guides/source | |
parent | 13e4b02a5c603b9368448febe09254e2b2dcbc1a (diff) | |
download | rails-14dd6c4d2f978d743269cf1096f0ad551a32d240.tar.gz rails-14dd6c4d2f978d743269cf1096f0ad551a32d240.tar.bz2 rails-14dd6c4d2f978d743269cf1096f0ad551a32d240.zip |
add warning about options_from_collection_for_select
Diffstat (limited to 'railties/doc/guides/source')
-rw-r--r-- | railties/doc/guides/source/form_helpers.txt | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/railties/doc/guides/source/form_helpers.txt b/railties/doc/guides/source/form_helpers.txt index a17c7e5249..bac3496b86 100644 --- a/railties/doc/guides/source/form_helpers.txt +++ b/railties/doc/guides/source/form_helpers.txt @@ -436,7 +436,7 @@ As with other helpers, if you were to use `select` helper on a form builder scop <%= f.select(:city_id, ...) %> ---------------------------------------------------------------------------- -[WARNING] +[WARNING] ============================= If you are using `select` (or similar helpers such as `collection_select`, `select_tag`) to set a `belongs_to` association you must pass the name of the foreign key (in the example above `city_id`), not the name of association itself. @@ -462,7 +462,6 @@ This is a perfectly valid solution, but Rails provides a less verbose alternativ ---------------------------------------------------------------------------- <%= options_from_collection_for_select(City.all, :id, :name) %> ---------------------------------------------------------------------------- - As the name implies, this only generates option tags. To generate a working select box you would need to use it in conjunction with `select_tag`, just as you would with `options_for_select`. When working with model objects, just as `select` combines `select_tag` and `options_for_select`, `collection_select` combines `select_tag` with `options_from_collection_for_select`. ---------------------------------------------------------------------------- @@ -471,6 +470,11 @@ As the name implies, this only generates option tags. To generate a working sele 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. +============================= + Time zone and country select ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |