加载 Rails Server 时出现问题(3.0.11,ruby 1.9.2),没有要加载的文件——sprockets/railtie (LoadError)
使用 Hartl 教程。
命令:rails s
响应:
/Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in `require': no such file to load -- sprockets/railtie (LoadError)
from /Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in `<top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:28:in `require'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:28:in `block in <top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:27:in `tap'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
下面的 application.rb 文件
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
#require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
#Bundler.require(:default, :assets, Rails.env)
end
module SampleApp
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
end
end
尝试注释掉链轮,只是产生了更多问题(不幸的是,没有任何结果)。
WUG的想法?
Using the Hartl tutorial.
Command: rails s
Response:
/Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in `require': no such file to load -- sprockets/railtie (LoadError)
from /Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in `<top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:28:in `require'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:28:in `block in <top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:27:in `tap'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
application.rb file below
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
#require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
#Bundler.require(:default, :assets, Rails.env)
end
module SampleApp
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
end
end
Tried commenting out sprockets, just created more problems (and nothing came of that, unfortunately).
WUG thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已将应用程序降级到 Rails 3.0,但您的应用程序仍有许多地方仅引用 3.1 的方法或文件。
sprockets/railtie 就是其中之一,您的environment.rb 中也会有涉及资产管道的设置,可能还有其他一些设置(我会想到包装参数的内容)。您至少需要删除所有这些。
作为 Rails 新手,我强烈建议您从您正在学习的教程所针对的 Rails 版本开始,并坚持使用它。
You've downgraded your app to rails 3.0 but there are still a number of places with your application references 3.1 only methods or files.
sprockets/railtie is one of those, there will also be settings in your environment.rb referring to the asset pipeline and probably some others too (the wrap params stuff springs to mind). You would need at the very least to remove all of those.
As someone new to rails I'd strongly suggest you start with the version of rails the tutorial you are following was written for and stick with it.