您好我正在将Rails 2应用升级到Rails 3。
当我想运行类似:rails c
,rake -T
等的内容时,会抛出这样的内容:
$ rails c
/usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/railtie/configuration.rb:77:in `method_missing': undefined method `assets' for #<Rails::Application::Configuration:0xb6569120> (NoMethodError)
from /home/neoriddle/proyectos/interkids/config/application.rb:49
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21
from script/rails:6:in `require'
from script/rails:6
这是rails c
,下一个日志正在运行rake -T
:
$ rake -T --trace
rake aborted!
undefined method `assets' for #<Rails::Application::Configuration:0xb658aa64>
/usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/railtie/configuration.rb:77:in `method_missing'
/home/neoriddle/proyectos/interkids/config/application.rb:49
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/neoriddle/proyectos/interkids/Rakefile:5
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
你有什么想法可以解决这个问题吗?
答案 0 :(得分:10)
资产管道直到rails 3.1才被包括在内。将rails gem(和app)升级到rails 3.1 +。
答案 1 :(得分:1)
我遇到了同样的问题,但在下面解决了。
Ruby -v: 3.0.2 Rails -v: 6.1.3
config/application.rb
require "sprockets/railtie”
终端
$ mkdir -p app/assets/config && echo '{}' > app/assets/config/manifest.js
答案 2 :(得分:0)
我的应用是api_only
,因此Rails在生成新资源时跳过了创建资产的操作。
我从config.assets
和development.rb
中删除了对production.rb
的引用,并且有效。
从本质上讲,如果您的应用不需要assets
,则可以将其删除。