I am a rails newbie trying to implement caching for my app. I installed memcached and configured it in my development.rb as follows:
config.action_controller.perform_caching = true
config.cache_store = :mem_cache_store
I have a controller ProductsController that shows user specific products when they are logged in.
class ProductsController < ApplicationController
caches_action :index, :layout => false
before_filter :require_user
def index
@user.products
end
end
The route for index action is: /products
The problem is that when I login as
1) User A for the first time, rails hits my controller and caches the products action.
2) I logout and login as User B, it still logs me in as User A and shows products for User A and not User B. It doesn't even hit my controller.
The key probably is the route, in my memcached console I see that it's fetching based on the same key.
20 get views/localhost:3000/products
20 sending key views/localhost:3000/products
Is action caching not what I should use? How would I cache and display user specific products?
Thanks for your help.