提交 9f98cf55 编写于 作者: C Carlos Antonio da Silva

Rework form helper example to use Person.new

The previous change 92a3c8dc 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]
上级 30645330
......@@ -67,10 +67,10 @@ module Helpers
#
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册