1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update GitHub gist api link and fix documentation in api_app page [ci skip]

The GitHub gist API page is out of date. This commit replaces it with
the new link.

Also, removed unnecessary commas, added missing fullstop and fixed
a ruby snippet which wasn't rendered correctly before.
This commit is contained in:
assain 2020-08-06 20:40:49 +05:30
parent 8654891cc7
commit 0f4de21b57

View file

@ -93,7 +93,7 @@ Handled at the Action Pack layer:
means not having to spend time thinking about how to model your API in terms means not having to spend time thinking about how to model your API in terms
of HTTP. of HTTP.
- URL Generation: The flip side of routing is URL generation. A good API based - URL Generation: The flip side of routing is URL generation. A good API based
on HTTP includes URLs (see [the GitHub Gist API](https://developer.github.com/v3/gists/) on HTTP includes URLs (see [the GitHub Gist API](https://docs.github.com/en/rest/reference/gists)
for an example). for an example).
- Header and Redirection Responses: `head :no_content` and - Header and Redirection Responses: `head :no_content` and
`redirect_to user_url(current_user)` come in handy. Sure, you could manually `redirect_to user_url(current_user)` come in handy. Sure, you could manually
@ -350,8 +350,12 @@ Instead of the initializer, you'll have to set the relevant options somewhere be
built (like `config/application.rb`) and pass them to your preferred middleware, like this: built (like `config/application.rb`) and pass them to your preferred middleware, like this:
```ruby ```ruby
config.session_store :cookie_store, key: '_interslice_session' # <-- this also configures session_options for use below # This also configures session_options for use below
config.middleware.use ActionDispatch::Cookies # Required for all session management (regardless of session_store) config.session_store :cookie_store, key: '_interslice_session'
# Required for all session management (regardless of session_store)
config.middleware.use ActionDispatch::Cookies
config.middleware.use config.session_store, config.session_options config.middleware.use config.session_store, config.session_options
``` ```
@ -405,7 +409,7 @@ controller modules by default:
more information regarding this). more information regarding this).
- `ActionController::ParamsWrapper`: Wraps the parameters hash into a nested hash, - `ActionController::ParamsWrapper`: Wraps the parameters hash into a nested hash,
so that you don't have to specify root elements sending POST requests for instance. so that you don't have to specify root elements sending POST requests for instance.
- `ActionController::Head`: Support for returning a response with no content, only headers - `ActionController::Head`: Support for returning a response with no content, only headers.
Other plugins may add additional modules. You can get a list of all modules Other plugins may add additional modules. You can get a list of all modules
included into `ActionController::API` in the rails console: included into `ActionController::API` in the rails console:
@ -433,21 +437,22 @@ Some common modules you might want to add:
- `AbstractController::Translation`: Support for the `l` and `t` localization - `AbstractController::Translation`: Support for the `l` and `t` localization
and translation methods. and translation methods.
- Support for basic, digest, or token HTTP authentication: - Support for basic, digest, or token HTTP authentication:
* `ActionController::HttpAuthentication::Basic::ControllerMethods`, * `ActionController::HttpAuthentication::Basic::ControllerMethods`
* `ActionController::HttpAuthentication::Digest::ControllerMethods`, * `ActionController::HttpAuthentication::Digest::ControllerMethods`
* `ActionController::HttpAuthentication::Token::ControllerMethods` * `ActionController::HttpAuthentication::Token::ControllerMethods`
- `ActionView::Layouts`: Support for layouts when rendering. - `ActionView::Layouts`: Support for layouts when rendering.
- `ActionController::MimeResponds`: Support for `respond_to`. - `ActionController::MimeResponds`: Support for `respond_to`.
- `ActionController::Cookies`: Support for `cookies`, which includes - `ActionController::Cookies`: Support for `cookies`, which includes
support for signed and encrypted cookies. This requires the cookies middleware. support for signed and encrypted cookies. This requires the cookies middleware.
- `ActionController::Caching`: Support view caching for the API controller. Please notice that - `ActionController::Caching`: Support view caching for the API controller. Please note
you will need to manually specify cache store inside the controller like: that you will need to manually specify the cache store inside the controller like this:
```ruby
class ApplicationController < ActionController::API ```ruby
include ::ActionController::Caching class ApplicationController < ActionController::API
self.cache_store = :mem_cache_store include ::ActionController::Caching
end self.cache_store = :mem_cache_store
``` end
```
Rails does *not* pass this configuration automatically. Rails does *not* pass this configuration automatically.
The best place to add a module is in your `ApplicationController`, but you can The best place to add a module is in your `ApplicationController`, but you can