Skip to content

NoMethodError (undefined method `fetch_or_store' for #<ThreadSafe::Cache:0x007fcf70821378>) #929

Closed
@eliduke

Description

I just upgraded my AMS gem to 0.10.0.rc1 in hopes of getting some better caching functionality. I am trying to cache some App Label and the serializer there looks like this:

class AppLabelSerializer < ActiveModel::Serializer
  cache key: 'app_label', expires_in: 3.hours
  attributes :id, :key, :label, :label_plural

  def key
    object.app_label_dictionary.key
  end

end

And then I hit one of the AppLabel end points with PostMan and I get this error:

NoMethodError (undefined method `fetch_or_store' for #<ThreadSafe::Cache:0x007fcf70821378>):
  app/controllers/v1/app_labels_controller.rb:22:in `auth_index'

I checked app_labels_controller.rb on line 22 and it is this method:

def auth_index
  render json: AppLabel.non_event
end

Which is calling an AppLabel scope:

scope :non_event, -> {joins(:app_label_dictionary).where(app_label_dictionary: {event_label: false} )}

I'm not familiar enough with AMS caching or Rails' Threadsafe elements to know what's going on here.

Any thoughts?

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions