-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of ActionController::API #46
Comments
@abrisse i included these modules, but action_caching still doens't seem to work.
p.s. I have added the gem. |
I just inherited from ActionController::Base and now things do work. Still think this could be address though. |
Facing same issue. |
Are there any better solutions than inheriting from |
This mixin seems to be working for me: # Have Rails 5 --api app play nicely with actionpack caching
module Cacheable
def self.prepended(klass)
klass.class_eval do
include ActionController::Caching
include ActionController::Caching::Actions
attr_accessor :action_has_layout
def self.cache_store
@cache_store ||= begin
store = Rails.application.config.cache_store
ActiveSupport::Cache.lookup_store(store)
end
end
end
end
def cache_store
@cache_store ||= begin
store = Rails.application.config.cache_store
ActiveSupport::Cache.lookup_store(store)
end
end
end class PostsController < ApplicationController
prepend Cacheable
end |
@richmolj looks cool, thanks! |
@richmolj hey, I've just tested this stuff, and turns out the code "works" with this mixin, e.g. no errors, but also no actual caching performed (and it is enabled), when I switch it back to inheritance from Under "no caching performed" I mean that with action that works with external API, it takes 2000ms to respond, and it responds with same 2000ms every time. And when I use inheritance from |
@rafaelfranca perhaps You could take a look on it? |
@FunkyloverOne it's actually been a while since I implemented this, so I don't have all the details. I know it has been working for me in production for a couple months, but maybe I missed some other config. You might want to try mixing it in to the controller subclass; I think I had problems with |
Currently this gem does not bring caching features to ActionController::API because:
Is there any specific reason for that?
The text was updated successfully, but these errors were encountered: