Skip to content
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

Issue with controller_path for cache keys #13

Open
mmhan opened this issue Sep 24, 2020 · 1 comment · May be fixed by #15
Open

Issue with controller_path for cache keys #13

mmhan opened this issue Sep 24, 2020 · 1 comment · May be fixed by #15

Comments

@mmhan
Copy link

mmhan commented Sep 24, 2020

controller_path seems to be used for both cache keys and view paths

The method is as seen below.

https://github.com/trailblazer/trailblazer-cells/blob/master/lib/trailblazer/cell.rb#L34:L37

Currently it is producing duplicate cache keys for different cells as below

# Comment::Cell::Show #=> comment/view/
# Comment::Cell::Summary #=> comment/views/

My expectation is that cache keys should be

# Comment::Cell::Show #=> comment/view/show/
# Comment::Cell::Summary #=> comment/views/summary/
@mmhan
Copy link
Author

mmhan commented Sep 24, 2020

Although it is arguable that I should be using states for Comment::Cell::Show and Comment::Cell::Summary, for my particular use case it is necessary. My current work around is override state_cache_key as below.

class Application::Cell < Trailblazer::Cell
  class << self
    # Computes the complete, namespaced cache key for +state+.
    def state_cache_key(state, key_parts={})
      last_name = util.underscore(name.sub(/(.+::Cell::)/, ''))
      expand_cache_key([controller_path, last_name, state, key_parts])
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant