From 9f98cf556de5c997c31a86bc19f7f280f337122f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 21 Mar 2015 14:56:24 -0300 Subject: 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] --- actionview/lib/action_view/helpers/form_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionview/lib/action_view/helpers') 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 params[:person] with the person attributes - # set in the form. That hash is ready to be passed to Person.create: + # set in the form. That hash is ready to be passed to Person.new: # - # @person = Person.create(params[:person]) - # if @person.valid? + # @person = Person.new(params[:person]) + # if @person.save # # success # else # # error handling -- cgit v1.2.3