'cache' method undefined for ActiveModel::Serializer
Trying to test AMS caching here. The class is missing the method all together. Any ideas? Using gem version 0.9.3. Cache config is redis_store
same problem. there is an alternative. i can propose a more complex hook, if you trying to cache object in collection, with custom name serializer. for example:
users = User.all
users = users.map do |user|
key = "UserShortSerializer-#{user.id}-#{user.updated_at.to_i}"
Rails.cache.fetch(key, expires_in: 3.hours) do
UserShortSerializer.new(user, meta: {...}, scope: view_context, root: false).attributes
end
end
render json: {users: users, ...}
OR you can use 0.8 Anyone knows, 0.9 much more faster than 0.8/0.10? please correct me if i wrong
Btw - I'm not set on 0.9.x. It happened to be the version installed by gem. I'm open to the best supported version. Just let me know which one that is. Thanks
@wasaylor the greatest version will definitively be the 0.10.0 (it may become 1.0). The thing is that it still wasn't officially launched, but we are already conducting some productions tests with it. I'm not so sure if 0.8 would be a easy trade, but you should give it a try. You might also want to test 0.10.0, but use it carefully and help us by reporting if you find a bug.
@wasaylor 0.10.0 is used by us in production and works stable.
awesome! btw @ipkes 0.10 is faster then 0.9, I made some benchmarks, check it out on AMS talk at RailsConf
After update to 0.10 i get an error saying wrong number of arguments (1 for 0) when calling render.
def index
@articles = SearchArticlesCommand.new(params).execute
render json: @articles, status: :ok
end
Hey @atbyrd, I'm sorry to hear that, I'm not sure if you still have this problem. If you do, could you please open a new issue for that letting us know your Rails version and with you are use ams 0.10 rc1, rc2 or master?
Just to be clear, is cached still not yet supported in 0.10.0.rc4
On that version I'm still getting:
NameError (undefined local variable or method 'cached' for PersonSerializer:Class):
app/serializers/person_serializer.rb:2:in '<class:PersonSerializer>'
app/serializers/person_serializer.rb:1:in '<top (required)>'
app/controllers/api/v1/people_controller.rb:21:in 'index'
@jlehman per docs, method name in 0.10.x is cache