diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-08-21 19:18:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-21 19:18:59 +0200 |
commit | 39e6eea9e54c93f836d79f0614f463bdcf95bab5 (patch) | |
tree | dc35cd87a0314007e3d6c3ea66b8b3c31c35352d /actionview | |
parent | c20b40c532ef5ec4f2dea647832ff8ffd3603816 (diff) | |
parent | 3639ca0cfbaa3afccd046868fbc279b36aa1330e (diff) | |
download | rails-39e6eea9e54c93f836d79f0614f463bdcf95bab5.tar.gz rails-39e6eea9e54c93f836d79f0614f463bdcf95bab5.tar.bz2 rails-39e6eea9e54c93f836d79f0614f463bdcf95bab5.zip |
Merge pull request #28912 from kaspth/getting-started-form-with
[ci skip] form_with in the getting started guide.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/helpers/form_helper.rb | 30 |
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 |