aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorFrederick Cheung <frederick.cheung@gmail.com>2009-01-24 15:04:46 +0000
committerFrederick Cheung <frederick.cheung@gmail.com>2009-01-24 15:04:46 +0000
commit9b93620c17e7957d0039a0a76148ca2306a2f042 (patch)
tree1ebe1276a939ee19517d19349c6dfa50e96f31c2 /railties
parent10dc4bf92c8e84d1fa48d28a08c3bbdd6f099b0f (diff)
downloadrails-9b93620c17e7957d0039a0a76148ca2306a2f042.tar.gz
rails-9b93620c17e7957d0039a0a76148ca2306a2f042.tar.bz2
rails-9b93620c17e7957d0039a0a76148ca2306a2f042.zip
could -> can when appropriate
Diffstat (limited to 'railties')
-rw-r--r--railties/doc/guides/source/form_helpers.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/doc/guides/source/form_helpers.txt b/railties/doc/guides/source/form_helpers.txt
index 059a537dd1..8d2cfd1f8d 100644
--- a/railties/doc/guides/source/form_helpers.txt
+++ b/railties/doc/guides/source/form_helpers.txt
@@ -198,7 +198,7 @@ Dealing With Model Objects
Model object helpers
~~~~~~~~~~~~~~~~~~~~~~
-A particularly common task for a form is editing or creating a model object. While the `*_tag` helpers could certainly be used for this task they are somewhat verbose as for each tag you would have to ensure the correct parameter name is used and set the default value of the input appropriately. Rails provides helpers tailored to this task. These helpers lack the _tag suffix, for example `text_field`, `text_area`.
+A particularly common task for a form is editing or creating a model object. While the `*_tag` helpers can certainly be used for this task they are somewhat verbose as for each tag you would have to ensure the correct parameter name is used and set the default value of the input appropriately. Rails provides helpers tailored to this task. These helpers lack the _tag suffix, for example `text_field`, `text_area`.
For these helpers the first argument is the name of an instance variable and the second is the name of a method (usually an attribute) to call on that object. Rails will set the value of the input control to the return value of that method for the object and set an appropriate input name. If your controller has defined `@person` and that person's name is Henry then a form containing:
@@ -724,7 +724,7 @@ This will result in a `params` hash that looks like
{'person' => {'name' => 'Bob', 'address' => { '23' => {'city' => 'Paris'}, '45' => {'city' => 'London'} }}}
--------
-Rails knows that all these inputs should be part of the person hash because you called `fields_for` on the first form builder. By specifying an `:index` option you're telling rails that instead of naming the inputs `person[address][city]` it should insert that index surrounded by [] between the address and the city. If you pass an Active Record object as we did then Rails will call `to_param` on it, which by default returns the database id. This is often useful as it is then easy to locate which Address record should be modified. You could pass numbers with some other significance, strings or even nil (which will result in an array parameter being created).
+Rails knows that all these inputs should be part of the person hash because you called `fields_for` on the first form builder. By specifying an `:index` option you're telling rails that instead of naming the inputs `person[address][city]` it should insert that index surrounded by [] between the address and the city. If you pass an Active Record object as we did then Rails will call `to_param` on it, which by default returns the database id. This is often useful as it is then easy to locate which Address record should be modified. You can pass numbers with some other significance, strings or even nil (which will result in an array parameter being created).
To create more intricate nestings, you can specify the first part of the input name (`person[address]` in the previous example) explicitly, for example
--------