aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-04-27 13:30:40 -0700
committerKasper Timm Hansen <kaspth@gmail.com>2017-08-21 19:16:50 +0200
commit3639ca0cfbaa3afccd046868fbc279b36aa1330e (patch)
tree6113c5f0eb5d10a96d32d983ed4536c0b9232548 /actionview
parente183dc195a965371b1edc3ea18c54910758c32e3 (diff)
downloadrails-3639ca0cfbaa3afccd046868fbc279b36aa1330e.tar.gz
rails-3639ca0cfbaa3afccd046868fbc279b36aa1330e.tar.bz2
rails-3639ca0cfbaa3afccd046868fbc279b36aa1330e.zip
[ci skip] form_with in the getting started guide.
Add back a bit about a resource oriented style of routing.
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index e5a2f7e520..bcda066837 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -543,6 +543,36 @@ module ActionView
# and adds an authenticity token needed for cross site request forgery
# protection.
#
+ # === Resource-oriented style
+ #
+ # In many of the examples just shown, the +:model+ passed to +form_with+
+ # is a _resource_. It corresponds to a set of RESTful routes, most likely
+ # defined via +resources+ in <tt>config/routes.rb</tt>.
+ #
+ # So when passing such a model record, Rails infers the URL and method.
+ #
+ # <%= form_with model: @post do |form| %>
+ # ...
+ # <% end %>
+ #
+ # is then equivalent to something like:
+ #
+ # <%= form_with scope: :post, url: post_path(@post), method: :patch do |form| %>
+ # ...
+ # <% end %>
+ #
+ # And for a new record
+ #
+ # <%= form_with model: Post.new do |form| %>
+ # ...
+ # <% end %>
+ #
+ # is equivalent to something like:
+ #
+ # <%= form_with scope: :post, url: posts_path do |form| %>
+ # ...
+ # <% end %>
+ #
# ==== +form_with+ options
#
# * <tt>:url</tt> - The URL the form submits to. Akin to values passed to