提交 3e3ed1ed 编写于 作者: V Vijay Dev

Merge pull request #13937 from ktaragorn/guides_fixes

Guides fixes
...@@ -1018,7 +1018,8 @@ The X-Sendfile header is a directive to the web server to ignore the response ...@@ -1018,7 +1018,8 @@ The X-Sendfile header is a directive to the web server to ignore the response
from the application, and instead serve a specified file from disk. This option from the application, and instead serve a specified file from disk. This option
is off by default, but can be enabled if your server supports it. When enabled, is off by default, but can be enabled if your server supports it. When enabled,
this passes responsibility for serving the file to the web server, which is this passes responsibility for serving the file to the web server, which is
faster. faster. Have a look at [send_file](http://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_file)
on how to use this feature.
Apache and nginx support this option, which can be enabled in Apache and nginx support this option, which can be enabled in
`config/environments/production.rb`: `config/environments/production.rb`:
...@@ -1033,6 +1034,10 @@ option, take care to paste this configuration option only into `production.rb` ...@@ -1033,6 +1034,10 @@ option, take care to paste this configuration option only into `production.rb`
and any other environments you define with production behavior (not and any other environments you define with production behavior (not
`application.rb`). `application.rb`).
TIP: For further details have a look at the docs of your production web server:
- [Apache](https://tn123.org/mod_xsendfile/)
- [Nginx](http://wiki.nginx.org/XSendfile)
Assets Cache Store Assets Cache Store
------------------ ------------------
......
...@@ -1119,7 +1119,11 @@ The `method: :patch` option tells Rails that we want this form to be submitted ...@@ -1119,7 +1119,11 @@ The `method: :patch` option tells Rails that we want this form to be submitted
via the `PATCH` HTTP method which is the HTTP method you're expected to use to via the `PATCH` HTTP method which is the HTTP method you're expected to use to
**update** resources according to the REST protocol. **update** resources according to the REST protocol.
TIP: By default forms built with the _form_for_ helper are sent via `POST`. The first parameter of the `form_tag` can be an object, say, `@article` which would
cause the helper to fill in the form with the fields of the object. Passing in a
symbol (`:article`) with the same name as the instance variable (`@article`) also
automagically leads to the same behavior. This is what is happening here. More details
can be found in [form_for documentation](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for).
Next we need to create the `update` action in Next we need to create the `update` action in
`app/controllers/articles_controller.rb`: `app/controllers/articles_controller.rb`:
...@@ -1390,7 +1394,9 @@ class CreateComments < ActiveRecord::Migration ...@@ -1390,7 +1394,9 @@ class CreateComments < ActiveRecord::Migration
create_table :comments do |t| create_table :comments do |t|
t.string :commenter t.string :commenter
t.text :body t.text :body
t.references :article, index: true
# this line adds an integer column called `article_id`.
t.references :article, index: true
t.timestamps t.timestamps
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册