Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 334
Linus Oleander Avatar asked Apr 07 '13 13:04

Linus Oleander


2 Answers

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'
like image 145
Aleksei Matiushkin Avatar answered Sep 19 '22 11:09

Aleksei Matiushkin


The problem is in Rails 4, they have extracted cache part into separate gems

if you are getting error for action caching then you need to add below gem

gem 'actionpack-action_caching'

for page caching have to add

gem 'actionpack-page_caching'

I also played around then I figure out that, have not added gem to do the same.

hope that will works. Thank you.

like image 29
Rameshwar Vyevhare Avatar answered Sep 19 '22 11:09

Rameshwar Vyevhare