ruby-on-rails - 捆绑控制台因未初始化常量 Rails 而失败

标签 ruby-on-rails ruby ruby-on-rails-4

我已经使用 rails plugin new Foobar --full --mountable 命令创建了一个新的 Rails 引擎。运行 bundle console 时,我得到 uninitialized constant Rails 这是为什么?

Resolving dependencies...
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:2:in `<module:Foobar>': uninitialized constant Rails (NameError)
    from /Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:1:in `<top (required)>'
    from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `require'
    from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `<top (required)>'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/cli.rb:664:in `console'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/vendor/thor/command.rb:27:in `run'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_command'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/vendor/thor.rb:363:in `dispatch'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/vendor/thor/base.rb:438:in `start'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/cli.rb:10:in `start'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/bin/bundle:22:in `block in <top (required)>'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/bin/bundle:22:in `<top (required)>'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/bin/bundle:23:in `load'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@global/bin/bundle:23:in `<main>'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@foobar/bin/ruby_executable_hooks:15:in `eval'
    from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353@foobar/bin/ruby_executable_hooks:15:in `<main>'

最佳答案

Foobar/lib/foobar/engine.rb 文件中添加 require 'rails' 对我有用。我从 here 得到了答案.

关于ruby-on-rails - 捆绑控制台因未初始化常量 Rails 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21312597/

相关文章:

ruby-on-rails - 使用 rspec 时如何打印当前页面响应

ruby-on-rails - validates_inclusion_of :in => [true, false] 允许字符串和 Fixnums

ruby-on-rails - 模块的 Rails 未定义方法

sql - 使用Rails 4在日志中显示SQL查询

mysql - Rails 4.2 Query 3模型以及belongs_to和has_one无法根据子属性获取父级

ruby-on-rails - 如何将Kafka客户端添加到Rails Docker部署中?

ruby-on-rails - rails 3路线: Default format and also limited formats

Ruby 方法拦截

ruby-on-rails - Rails 4 中的 JS 和 CSS

ruby-on-rails - 无法使用 Paypal 和 Rails 应用程序。通知 Paypal 不工作