加载 Rails Server 时出现问题(3.0.11,ruby 1.9.2),没有要加载的文件——sprockets/railtie (LoadError)

发布于 2024-12-25 03:46:10 字数 1797 浏览 1 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七禾 2025-01-01 03:46:10

您已将应用程序降级到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文