当前位置:  开发笔记 > 后端 > 正文

使用rails尝试angularjs时出错:未定义方法`register_engine'代表nil:NilClass(NoMethodError)

如何解决《使用rails尝试angularjs时出错:未定义方法`register_engine'代表nil:NilClass(NoMethodError)》经验,为你挑选了1个好方法。

我是angularjs和rails的新手.在我的新公司中,我们必须在带有角度的轨道上使用红宝石.在单独使用railsjs和ruby on rails的教程之后,我正在尝试使用以下链接将两者结合起来:https: //thinkster.io/angular-rails#generating-activerecord-models 完成所有步骤后直到主题"当我运行rails s命令时,将前端与资产管道集成"(包括本主题中的步骤)会出现以下错误:

=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
**/home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/angular-rails-templates-0.1.4/lib/angular-rails-templates/engine.rb:49:in `block (2 levels) in ': undefined method `register_engine' for nil:NilClass (NoMethodError)**
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/angular-rails-templates-0.1.4/lib/angular-rails-templates/engine.rb:39:in `each'
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/angular-rails-templates-0.1.4/lib/angular-rails-templates/engine.rb:39:in `block in '
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /home/cb/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
    from /home/cb/flapper-news/config/environment.rb:5:in `'
    from /home/cb/flapper-news/config.ru:3:in `require'
    from /home/cb/flapper-news/config.ru:3:in `block in 
' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize' from /home/cb/flapper-news/config.ru:in `new' from /home/cb/flapper-news/config.ru:in `
' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/server.rb:208:in `app' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/railties-4.2.5/lib/rails/commands.rb:17:in `' from /home/cb/flapper-news/bin/rails:9:in `require' from /home/cb/flapper-news/bin/rails:9:in `' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/client/rails.rb:28:in `load' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/client/rails.rb:28:in `call' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/client/command.rb:7:in `call' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/client.rb:28:in `run' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/bin/spring:51:in `' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/binstub.rb:11:in `load' from /home/cb/.rvm/gems/ruby-2.2.3@flapper-news/gems/spring-1.6.0/lib/spring/binstub.rb:11:in `' from /home/cb/flapper-news/bin/spring:13:in `require' from /home/cb/flapper-news/bin/spring:13:in `' from bin/rails:3:in `load' from bin/rails:3:in `
'

使用rails版本4.2.5

以下是Gemfile的片段:

    source 'https://rubygems.org'

    gem 'angular-rails-templates'

    gem 'rails', '4.2.5'

    gem 'sqlite3'

    gem 'sass-rails', '~> 5.0'

    gem 'uglifier', '>= 1.3.0'

    gem 'jbuilder', '~> 2.0'

    gem 'sdoc', '~> 0.4.0', group: :doc


    group :development, :test do

      gem 'byebug'

    end

group :development do

gem 'web-console', '~> 2.0'

gem 'spring'

end

Mario.. 14

我遇到过同样的问题.这是一个与'链轮'有关的问题.尝试安装旧版本添加gem 'sprockets', '2.12.3'到您的gem文件,然后通过运行更新您的gem bundle update.它对我有用.



1> Mario..:

我遇到过同样的问题.这是一个与'链轮'有关的问题.尝试安装旧版本添加gem 'sprockets', '2.12.3'到您的gem文件,然后通过运行更新您的gem bundle update.它对我有用.


2.12.4也为我解决了问题,但没有以下内容:3.0.3,3.1.0,3.2.0,3.3.5,3.4.1.3.5.2.顺便说一句,我没有使用AngularJS.
推荐阅读
拾味湖
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有