Skip to content

private cache_path passed in as a symbol doesn't work in v1.2.0 #55

Open
@MarinaMurashev

Description

@MarinaMurashev

I'm running Rails 4.2.9 and Ruby 2.3.5. I just upgraded actionpack-action_caching gem from 1.1.1 to 1.2.0. Before, on v1.1.1 I was able to specify the cache_path with a symbolized method name (without the _url postfix), like this:

class MyController < ApplicationController
  caches_action :my_action, cache_path: :my_cache_path, if: :is_cacheable?

  def my_action
    ...
  end

  private

  def my_cache_path_url
    url_for(
      only_path: true, 
      action: "my_action", 
      format: "json", 
      page_number: params[:page],
      max_updated_at: MyModel.maximum(:updated_at).to_i,
    )
  end

  def is_cacheable?
    true
  end
end

After updating the gem to v1.2.0, this would only work if I wrapped the cache_path method in a new Proc with its full name including the _url portion:

caches_action :my_action, cache_path: Proc.new { my_cache_path_url }, if: :is_cacheable? # works

It also works with the short lambda syntax:

caches_action :my_action, cache_path: -> { my_cache_path_url }, if: :is_cacheable? # works

Can you verify whether v1.2.0 of the gem hurt the ability to pass in a symbolized url path name to cache_path?:

 caches_action :my_action, cache_path: :my_cache_path, if: :is_cacheable? # does not currently work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions