expiring action from a different controller
I've got the answer for that.
By default caches_action
ignores parameters.
And for getting the right fragment to be expired I did the following
expire_action store_url(host: my_host, store: store_name, locale: locale])
rails3 caching: expire fragment with extension
It appears that the problem was with routing setting default parameters. In the API controller, params[:format] was 'json' and in the Admin controller it was nil.
When I added this to my Admin controller:
params[:format] = 'json'
expire_action(:controller => 'api/books', :action => 'show', :id => @book.id, :format => 'json')
Then, the fragments in both controllers matched.
This let me back to my routes:
In my routes I had this:
namespace :api, :defaults => {:format => 'json'} do
resources :books, :only => [:show]
end
This caused params[:format] to be set in my api namespace. I didn't have anything in my admin namespace and apparently actionpack/ActionCachePath saw these two differently. Removing the defaults in the routes fixed the problem.
How do you expire an action for all formats in Rails? (expire_action)
I don't know of a better way than to explicitly expire each format unfortunately.
expire_action :action => :index
expire_action :action => :index, :format => 'json'
Rails caching: Expiring multiple pages for one action
I'm still interested in an answer to my original question and will change my accepted answer should a solution come up. That said, I ended up only caching the original page by checking if a page was specified at all:
caches_action :index, :if => Proc.new { params[:page].nil? }
Related Topics
How to Define a Simple Global Variable in an Rspec Test That Can Be Accesed by Helper Functions
Rake Test Very Slow in Windows
Ruby Enterprise Edition VS Ruby 1.9
Convert Ip Address to 32 Bit Integer in Ruby
Unexpected Keyword_End, Expecting $End (Syntaxerror)
Rails S Return: [Bug] Segmentation Fault
Fresh Install of Rails and Getting Openssl Errors: "Already Initialized Constant Openssl"
How to Change Environment Variables When Running Rspec for Ruby
Remove All Data from Active Storage
Rails Activerecord Create or Find
Garbage Collector in Ruby 2.2 Provokes Unexpected Cow
Ruby Minitest Assert_Output Syntax
Encoding Issues in JavaScript Files Using Rails Asset Pipeline
Web Page Scraping Gems/Tools Available in Ruby
How to Define a Method in Ruby Using Splat and an Optional Hash at the Same Time