From 3639ca0cfbaa3afccd046868fbc279b36aa1330e Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Thu, 27 Apr 2017 13:30:40 -0700 Subject: [ci skip] form_with in the getting started guide. Add back a bit about a resource oriented style of routing. --- actionview/lib/action_view/helpers/form_helper.rb | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'actionview') 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 config/routes.rb. + # + # 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 # # * :url - The URL the form submits to. Akin to values passed to -- cgit v1.2.3