diff options
author | st0012 <stan001212@gmail.com> | 2019-04-23 10:31:37 +0800 |
---|---|---|
committer | st0012 <stan001212@gmail.com> | 2019-04-23 10:31:37 +0800 |
commit | e75452a70906719f2dfb7ea7dbcdaf4f2b144d38 (patch) | |
tree | 5def4cb80d5a6500c30436636e92762a55932f88 | |
parent | 16dae7684edc480ee3fe65dfff8e19989402c987 (diff) | |
download | rails-e75452a70906719f2dfb7ea7dbcdaf4f2b144d38.tar.gz rails-e75452a70906719f2dfb7ea7dbcdaf4f2b144d38.tar.bz2 rails-e75452a70906719f2dfb7ea7dbcdaf4f2b144d38.zip |
Add ActionController::Caching into api app's document
Rails doesn't support view caching in api controllers by default but the
document didn't clearerly declare this nor the manual config needed
after including the module manually. So we'll see people get confused
like #35602.
-rw-r--r-- | guides/source/api_app.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/guides/source/api_app.md b/guides/source/api_app.md index b8b6cb7874..181d39e7e0 100644 --- a/guides/source/api_app.md +++ b/guides/source/api_app.md @@ -420,6 +420,15 @@ Some common modules you might want to add: - `ActionController::MimeResponds`: Support for `respond_to`. - `ActionController::Cookies`: Support for `cookies`, which includes support for signed and encrypted cookies. This requires the cookies middleware. +- `ActionController::Caching`: Support view caching for the API controller. Please notice that + you will need to manually specify cache store inside the controller like: + ```ruby + class ApplicationController < ActionController::API + include ::ActionController::Caching + self.cache_store = :mem_cached_store + end + ``` + Rails does *not* pass this configuration automatically. The best place to add a module is in your `ApplicationController`, but you can also add modules to individual controllers. |