aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2015-03-21 14:56:24 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2015-03-21 14:56:24 -0300
commit9f98cf556de5c997c31a86bc19f7f280f337122f (patch)
tree8aa6a0c91397358d5b914aa84da1cf83b063b0f4 /actionview/lib/action_view/helpers/form_helper.rb
parent3064533076c83517c7297adeea473fe52f0bb454 (diff)
downloadrails-9f98cf556de5c997c31a86bc19f7f280f337122f.tar.gz
rails-9f98cf556de5c997c31a86bc19f7f280f337122f.tar.bz2
rails-9f98cf556de5c997c31a86bc19f7f280f337122f.zip
Rework form helper example to use Person.new
The previous change 92a3c8dcdf174dab5e8759031b6bbe6cd891fe3c improved this example, but calling .create + #valid? ends up running validations twice, and we don't want to showcase that. Lets use the normal use case of building a new object and calling #save on it, which is what a basic scaffold with Active Record does. [ci skip]
Diffstat (limited to 'actionview/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index 63bb4ce32f..f2a74ea647 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -67,10 +67,10 @@ module ActionView
#
# In particular, thanks to the conventions followed in the generated field names, the
# controller gets a nested hash <tt>params[:person]</tt> with the person attributes
- # set in the form. That hash is ready to be passed to <tt>Person.create</tt>:
+ # set in the form. That hash is ready to be passed to <tt>Person.new</tt>:
#
- # @person = Person.create(params[:person])
- # if @person.valid?
+ # @person = Person.new(params[:person])
+ # if @person.save
# # success
# else
# # error handling