我正在尝试使用rails 3 application
配置breadcrumbs_on_rails我添加了
gem 'breadcrumbs_on_rails'
进入我的gemfile
另外,我已经包含了BreadcrumbsOnRails :: ControllerMixin
require File.expand_path('../boot', __FILE__)
require 'rails/all'
include BreadcrumbsOnRails::ControllerMixin
if defined?(Bundler)
....
进入application.rb
但无论如何我总是得到错误:
runnerw.exe C:\Ruby\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /script/rails server -b 127.0.0.1 -p 3000 -e development
/config/application.rb:1:in `<top (required)>': uninitialized constant BreadcrumbsOnRails (NameError)
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
from /script/rails:6:in `require'
from /script/rails:6:in `<top (required)>'
如何解决此错误?感谢
答案 0 :(得分:1)
嗨朋友,在捆绑器加载你的宝石'breadcrumbs_on_rails'后,常量BreadcrumbsOnRails :: ControllerMixin将可用。
但是在Bundler加载gem之前你会使用BreadcrumbsOnRails :: ControllerMixin。
执行以下行后加载宝石。所以你必须使用
require 'rails/all'
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
include BreadcrumbsOnRails::ControllerMixin
以下是宝石的文档。
祝你好运。答案 1 :(得分:0)
查看@soundar提供的文档,我没有在源代码或文档中看到ControllerMixin。我也没有看到任何需要在config / application.rb
中放任何东西