Oleander Oleander - 2 years ago 213
Ruby Question

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

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

Answer Source

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'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download