Search code examples
ruby-on-railsrubyruby-on-rails-4ruby-2.0

undefined method `caches_action' for ApplicationController:Class


I'm trying to upgrade to rails 4 beta 1, but I've a bit of a problem.

This is, in short, how my application controller looks like.

class ApplicationController < ApplicationController
  caches_action :method
end

caches_action is moved out to it's own gem in Rails 4, so including the gem should fix the problem.

gem "actionpack-action_caching", github: "rails/actionpack-action_caching"

But when I run my requests specs or visit the application in a browser I get this error.

app/controllers/application_controller.rb:3:in `<class:ApplicationController>': undefined method `caches_action' for ApplicationController:Class (NoMethodError)

Why is that?

  • Rails 4.0.0.beta1
  • Ruby 2.0.0
  • Rspec 2.13.1

Solution

  • As the caching is not a part of core anymore, you need to explicitly require it in top of every file you use it in:

    require 'actionpack/action_caching'