diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2015-03-21 14:56:24 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2015-03-21 14:56:24 -0300 |
commit | 9f98cf556de5c997c31a86bc19f7f280f337122f (patch) | |
tree | 8aa6a0c91397358d5b914aa84da1cf83b063b0f4 /actionview/lib | |
parent | 3064533076c83517c7297adeea473fe52f0bb454 (diff) | |
download | rails-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')
-rw-r--r-- | actionview/lib/action_view/helpers/form_helper.rb | 6 |
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 |