ruby-on-rails – 删除mathjax-rails后的循环依赖性错误

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 删除mathjax-rails后的循环依赖性错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我的Gemfile目前看起来像
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','4.2.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails','~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier','>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails','~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer',platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc','~> 0.4.0',group: :doc

gem 'mathjax-rails','~> 2.5','>= 2.5.1'
gem 'bootstrap-sass','~> 3.3','>= 3.3.5.1'

# Use ActiveModel has_secure_password
# gem 'bcrypt','~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails',group: :development

group :development,:test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console','~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

它工作正常.有趣的是,一旦我删除mathjax-rails并尝试在生产模式下运行,我就会得到

/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_dispatch/routing/url_for.rb:99:in `append_features': cyclic include detected (ArgumentError)
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_dispatch/routing/url_for.rb:99:in `include'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_dispatch/routing/url_for.rb:99:in `block in <module:UrlFor>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/concern.rb:120:in `class_eval'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/concern.rb:120:in `append_features'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionview-4.2.4/lib/action_view/railtie.rb:41:in `include'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionview-4.2.4/lib/action_view/railtie.rb:41:in `block (2 levels) in <class:Railtie>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_controller/base.rb:266:in `<class:Base>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_controller/base.rb:164:in `<module:ActionController>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.4/lib/action_controller/base.rb:5:in `<top (required)>'
    from /root/StudySome/app/controllers/application_controller.rb:1:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:360:in `require_or_load'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:317:in `depend_on'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:233:in `require_dependency'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:471:in `each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:471:in `block in eager_load!'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:469:in `each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:469:in `eager_load!'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:346:in `eager_load!'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
    from /root/StudySome/config/environment.rb:5:in `<top (required)>'
    from /root/StudySome/config.ru:3:in `require'
    from /root/StudySome/config.ru:3:in `block in <main>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /root/StudySome/config.ru:in `new'
    from /root/StudySome/config.ru:in `<main>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:61:in `app'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
=> Booting WEBrick
=> Rails 4.2.4 application starting in production on http://159.203.240.211:80
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting

为什么?!我只是想从MathJax CDN加载MathJax …

解决方法

即使您删除了gem,您的代码中也可能会留下一些mathjax引用.在 usage instructions for gem中,似乎你必须在routes.rb以及app / views / layouts / application.html.erb中添加一些代码.如果那些引用存在,删除它们应该修复这个sissue.
原文链接:https://www.f2er.com/ruby/268057.html

猜你在找的Ruby相关文章