I'm using rabl_rails
for generating json for my rails app and caching most of them for faster response. Things work great for non logged in users but I also want to able to cache responses for logged in users with their ID append in the cache key but as per the documentation, instance variables are not available in the rabl template due to the way its designed. You can find it here https://github.com/ccocchi/rabl-rails#how-it-works
What I am trying to achieve is this
cache "api/v1/home/top_menu_data-#{@current_user.id}"
but this doesn't work according to the document.
Has anyone done this before ? How do I achieve this ?
PS: This is feasible with rabl
but not with rail_rails
as far as I know. Would love to know ideas on how to be able to do this.
Thanks in advance.
As per the discussion with developer of the gem, its found that it can't access any instance variables or params hash. The discussion could be found here
I started using rabl
for generating json for my views which works great.