Rake on Rails 3 problem

谁说胖子不能爱 提交于 2019-12-24 01:36:10

问题


I moved a Rails 2.3 application to Rails 3. The application actually works perfectly, but I have issue with rake tasks. It looks like the config in the environment file is not initialized correctly. the error I get is:

rake aborted!
undefined method `cache_classes=' for #<Hash:0x3c3e850>
/var/www/apps/nzar3/config/environments/development.rb:9
.....

The environment file is clean, and it works. Here the environments/development.rb

config.cache_classes = false
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs                         = true
config.action_controller.perform_caching             = false
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin

Any clue?


回答1:


Rails3 uses a different syntax for configuration of your application.

YourApp::Application.configure do
  config.cache_classes = false
end

Did you migrate your app by running rails /path/to/rails2/app?

Have a read of this good article for tips about upgrading to Rails 3.




回答2:


I had this problem also, it was related to the cache_fu plugin being installed. Removing cache_fu made the issue go away.




回答3:


Full config file

App::Application.configure do
 config.cache_classes = false
 config.whiny_nils = true
 config.action_controller.consider_all_requests_local = true
 config.action_view.debug_rjs                         = true
 config.action_controller.perform_caching             = false
 config.active_support.deprecation = :log
 config.action_dispatch.best_standards_support = :builtin
end



回答4:


I found out that it's only this rake task that uses ActionView doesn't work

namespace :cached_assets do
  desc "Regenerate aggregate/cached files"
  task :regenerate => :environment do
    include ActionView::Helpers::TagHelper
    include ActionView::Helpers::UrlHelper
    include ActionView::Helpers::AssetTagHelper
    stylesheet_link_tag :all, :cache => 'a'
    javascript_include_tag :defaults, :cache => 'b'
    javascript_include_tag "c.js", :cache => 'c'
  end
 end



回答5:


This worked for me: comment this portion

config.action_view.debug_rjs   = true

from environments/development.rb



来源:https://stackoverflow.com/questions/3782583/rake-on-rails-3-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!