Rails4和Devise(NoMethod错误) [英] Rails4 and Devise (NoMethod error)

查看:140
本文介绍了Rails4和Devise(NoMethod错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用rails gem在ruby上构建Web应用程序。
遵循本教程: http: //12devs.co.uk/articles/writing-a-web-application-with-ruby-on-rails/



一切都很好在我开始安装 Devise gem之前,请清除用户身份验证功能。



在执行 rails生成devise:安装



错误报告是这个史诗(看起来像我搞砸了一些依赖关系):

  sergey @ sergey-VirtualBox:〜/ Bookmarks $ rails generate devise:install 
/home/sergey/.rvm/gems/ruby -2.1.2 / gems / activerecord-4.1.0 / lib / active_record / dynamic_matchers.rb:26:在`method_missing'中:未定义的方法`devise'用于安装(调用'Install.connection'建立连接):Class来自/ home / sergey / Bookmarks / app / models / install的/home/sergey/Bookmarks/app/models/install.rb:4:in`< class:Install>'

.rb:1:在< top(required)>'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies .rb:443:在`load'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/l ib / active_support / dependencies.rb:443:在`block in load_file'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies .rb:633:在`new_constants_in'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:442:in` load_file'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:342:in`require_or_load'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:480:in`load_missing_constant'
from /home/sergey/.rvm /gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:180:in`const_missing'
from /home/sergey/.rvm/gems/ruby-2.1。 2 / gems / activesupport-4.1.0 / lib / active_support / inflector / methods.rb:238:在`const_get'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport -4.1.0 / lib / active_support / inflector / methods.rb:238:在`block i来自/home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in每个$ b定期调整
$ b从/home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in`inject'
从/ home /sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in`constantize'
from /home/sergey/.rvm /gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:552:in从/home/sergey/.rvm/gems/ruby-2.1获取
。 2 / gems / activesupport-4.1.0 / lib / active_support / dependencies.rb:583:在`constantize'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2 .4 / lib / devise.rb:297:在get
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping。 rb:77:在`to'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:72:in` modules '
from /home/sergey/.rvm /home/sergey/.rvm/gems/ruby-2.1中的/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:89:in`route'
。 2 / gems / devise-3.2.4 / lib / devise / mapping.rb:156:在`default_used_route'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2 .4 / lib / devise / mapping.rb:66:来自/home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise的`initialize'
。 rb:331:在`new'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:331:in`add_mapping'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:221:in`block in devise_for'
从/home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in$
从/ home / sergey /.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in`devise_for'
from / home / sergey / Bookmarks / config / routes.rb:2:在`block in< top(required)>'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actio npack-4.1.0 / lib / action_dispatch / routing / route_set.rb:335:在`instance_exec'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.0 /lib/action_dispatch/routing/route_set.rb:335:in`eval_block'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.0/lib/action_dispatch/路由/ route_set.rb:313:在`draw'
from /home/sergey/Bookmarks/config/routes.rb:1:in`< top(required)>'
from / home /sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in从/home/sergey/.rvm/gems载入'
/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in从/home/sergey/.rvm/gems/ruby-2.1载入'
'。 2 / gems / activesupport-4.1.0 / lib / active_support / dependencies.rb:232:在`load_dependency'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1 .0 / lib / active_support / dependencies.rb:241:在`load'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railtie s-4.1.0 / lib / rails / application / routes_reloader.rb:40:在`block in load_paths'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1 .0 / lib / rails / application / routes_reloader.rb:40:在`each'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/ rails / application / routes_reloader.rb:40:在`load_paths'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader .rb:16:在`reload!'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:26 :在`block in updater'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in`call'来自/ home /sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in的
$ / $ /sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:27:in`updater'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:7:in`execute_if_updated'
from / home / sergey / .rvm / gems / ruby​​-2.1.2 / gems / railties-4.1.0 / lib / rails / application / finisher.rb:71:在`block in< module:Finisher>'
from / home / sergey / .rvm / gems / ruby​​-2.1.2 / gems / railties-4.1.0 / lib / rails / initializable.rb:30:在`instance_exec'
from /home/sergey/.rvm/gems/ ruby-2.1.2 / gems / railties-4.1.0 / lib / rails / initializable.rb:30:在`run'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems /railties-4.1.0/lib/rails/initializable.rb:55:in`run in in run_initializers'
from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1。 0 / tsort.rb:226:在`block in tsort_each'
from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in来自/home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in的每个_strongly_connected_component'
中的`block(2个级别)'
来自/home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in`block in each_strongly_connected_component'
from /home/sergey/.rvm/ ruby / ruby​​-2.1.2 / lib / ruby​​ / 2.1.0 / tsort.rb:345:在each
from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby来自/home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345的`/ b

$在/home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in`tsort_each'
from / home中的`each_strongly_connected_component'
来自/home/sergey/.rvm/gems/ruby-2.1的/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in`tsort_each'
.2 / gems / railties-4.1.0 / lib / rails / initializable.rb:54:在`run_initializers'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties- 4.1.0 / lib / rails / application.rb:288:在`initialize!'
from /home/sergey/Bookmarks/config/environment.rb:5:in`< top(required)>'来自/home/sergey/.rvm/gems/ruby-2.1.2/gems/acti的
vesupport-4.1.0 / lib / active_support / dependencies.rb:247:在`require'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib /active_support/dependencies.rb:247:in`block in require'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies。 rb:232:在`load_dependency'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in`require '
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application.rb:264:in`require_environment!'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:147:in`require_application_and_environment!'
from / home / sergey /.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:133:in`generate_or_destroy'
from /home/sergey/.rvm/gems /ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:51:in`属来自/home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:inrun_command!的$'
'
from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands.rb:17:in`< top(required)>'
从bin / rails:4:在`require'
从bin / rails:4:在`< main>'

我使用的是Ubuntu 14托管在Oracle Virtualbox中。 Virtualbox在Windows 7上运行。
安装的ruby版本是:

  sergey @ sergey-VirtualBox:〜/ Bookmarks $ ruby -v 
ruby​​ 2.1.2p95(2014-05-08修订版45877)[x86_64-linux]

项目创建如下:

  rails新书签-T -d sqlite3 -B 

Gemfile.rb 内容是:

 源'https://rubygems.org'

#为用户授权设计宝石
宝石'devise','〜 > 3.2.4'
#Bundle edge Rails代替:gem'rails',github:'rails / rails'
gem'rails','4.1.0'
#使用sqlite3作为数据库对于活动记录
gem'sqlite3'
#使用SCSS作为样式表
gem'sass-rails','〜> 4.0.3'
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','> = 1.3.0'
#使用CoffeeScript for .js.coffee资产和视图
gem'coffee-rails','〜> 4.0.0'
#请参阅https://github.com/sstephenson/execjs#readme获取更多支持的运行时
#gem'therubyracer',平台::ruby

#使用jquery作为JavaScript库
gem'jquery-rails'
#Turbolinks使您的Web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem'turbolinks'
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder','〜> 2.0'
#bundle exec rake doc:rails在doc / api下生成API。
gem'sdoc','〜> 0.4.0',组::doc

#Spring通过保持应用程序在后台运行,加快开发速度。阅读更多:https://github.com/rails/spring
gem'spring',group::development

#使用ActiveModel has_secure_password
#gem'bcrypt',' 〜> 3.1.7'

#使用独角兽作为应用服务器
#gem'unicorn'

#使用Capistrano进行部署
#gem'capistrano- rails#,group::$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ / / / / / / / / / / / / / / / / / / / / / / / / / / / /]]]] pre>

使用 bundler 来管理宝石。
安装的rails宝石是:

  sergey @ sergey-VirtualBox:〜/书签$ bundle update 
获取宝贝元数据https://rubygems.org / ..........
从https://rubygems.org/ ..获取额外的元数据
解析依赖关系...
使用rake 10.3.2
使用i18n 0.6.11
使用json 1.8.1
使用minitest 5.4.0
使用thread_safe 0.3.4
使用tzinfo 1.2 .1
使用activesupport 4.1.0
使用builder 3.2.2
使用erubis 2.7.0
使用actionview 4.1.0
使用机架1.5.2
使用机架测试0.6.2
使用actionpack 4.1.0
使用mime类型1.25.1
使用polyglot 0.3.5
使用treetop 1.4.15
使用邮件2.5.4
使用actionmailer 4.1.0
使用activemodel 4.1.0
使用arel 5.0.1.20140414130214
使用activerecord 4.1.0
使用bcrypt 3.1.7
使用bundler 1.6.2
使用coffee-script-source 1.7.1
使用execjs 2.2.1
使用咖啡脚本2.3.0
使用thor 0.19。 1
U唱歌轨道4.1.0
使用咖啡轨道4.0.1
使用orm_adapter 0.5.0
使用守护者1.2.3
使用devise 3.2.4
使用远足1.2 .3
使用multi_json 1.10.1
使用jbuilder 2.1.2
使用jquery-rails 3.1.1
使用倾斜1.4.1
使用链轮2.11.0
使用链轮轨道2.1.3
使用rails 4.1.0
使用rdoc 4.1.1
使用sass 3.2.19
使用sass-rails 4.0.3
使用sdoc 0.4.0
使用弹簧1.1.3
使用sqlite3 1.3.9
使用turbolinks 2.2.2
使用uglifier 2.5.1
您的包是更新!

我知道这里有一个同样错误的问题(即使是类似的版本)为Ruby on Rails设置宝石安装



但没有答复,我试图提供更多的信息。



另外我尝试了这个答案,没有效果。



你能帮助我吗这里?

解决方案

最近我回到使用 devise 很可能这是依赖关系的问题。



不幸的是,我不知道究竟是什么错误,因为我刚刚卸载了可能会导致任何影响的所有内容我的Ruby安装和它的gems依赖关系并重新安装。



首先我删除了我的试用版,以便在适当的环境下进一步重新创建它。



然后我按照这个指南 rvm ruby​​ )。



这是一个 guide 用于安装 rails ,但是足够了只需 gem install rails



使用新鲜的Ruby重新创建我的试用版应用程序在Rails环境中,我仍然遵循此指南(与问题相同)。



此时间命令:

  rails g devise:install 

完美工作。



此外,我没有进一步的指导说明有任何问题。


I am learning how to build web application on ruby with rails gem. Following this tutorial: http://12devs.co.uk/articles/writing-a-web-application-with-ruby-on-rails/

All was good & clear before I started to install Devise gem for user authentication feature.

I am getting error after doing rails generate devise:install

Error report is this epic (looks like I messed up some dependencies somehow):

sergey@sergey-VirtualBox:~/Bookmarks$ rails generate devise:install
/home/sergey/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.0/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `devise' for Install (call 'Install.connection' to establish a connection):Class (NoMethodError)
    from /home/sergey/Bookmarks/app/models/install.rb:4:in `<class:Install>'
    from /home/sergey/Bookmarks/app/models/install.rb:1:in `<top (required)>'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:443:in `load'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:443:in `block in load_file'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:633:in `new_constants_in'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:442:in `load_file'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:342:in `require_or_load'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:480:in `load_missing_constant'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:180:in `const_missing'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:238:in `const_get'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:238:in `block in constantize'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in `each'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in `inject'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/inflector/methods.rb:236:in `constantize'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:552:in `get'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:583:in `constantize'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:297:in `get'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:77:in `to'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:72:in `modules'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:89:in `routes'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:156:in `default_used_route'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:66:in `initialize'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:331:in `new'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:331:in `add_mapping'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:221:in `block in devise_for'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in `each'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in `devise_for'
    from /home/sergey/Bookmarks/config/routes.rb:2:in `block in <top (required)>'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:335:in `instance_exec'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:335:in `eval_block'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:313:in `draw'
    from /home/sergey/Bookmarks/config/routes.rb:1:in `<top (required)>'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `block in load'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `each'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in `call'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in `execute'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application/finisher.rb:71:in `block in <module:Finisher>'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `run'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
    from /home/sergey/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application.rb:288:in `initialize!'
    from /home/sergey/Bookmarks/config/environment.rb:5:in `<top (required)>'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/application.rb:264:in `require_environment!'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:147:in `require_application_and_environment!'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:133:in `generate_or_destroy'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:51:in `generate'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /home/sergey/.rvm/gems/ruby-2.1.2/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

OS I am using is Ubuntu 14 hosted in Oracle Virtualbox. Virtualbox is running on Windows 7. Installed ruby version is:

sergey@sergey-VirtualBox:~/Bookmarks$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

Project created like this:

rails new Bookmarks -T -d sqlite3 -B

Gemfile.rb contents are:

source 'https://rubygems.org'

# Devise gem for User Authorisation
gem 'devise', '~> 3.2.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/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

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

# 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

# Use debugger
# gem 'debugger', group: [:development, :test]

Using bundler to manage gems. Installed rails gems are:

sergey@sergey-VirtualBox:~/Bookmarks$ bundle update
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.0
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.0
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.0
Using activemodel 4.1.0
Using arel 5.0.1.20140414130214
Using activerecord 4.1.0
Using bcrypt 3.1.7
Using bundler 1.6.2
Using coffee-script-source 1.7.1
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.0
Using coffee-rails 4.0.1
Using orm_adapter 0.5.0
Using warden 1.2.3
Using devise 3.2.4
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.2
Using jquery-rails 3.1.1
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.0
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.3
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.1
Your bundle is updated!

I know there is a question with same error here (even with similar versions) devise gem install for Ruby on Rails

But unanswered and I tried to provide more info.

Also I tried this answer, no effect.

Could you please help me out here?

解决方案

Recently I got back to my problem with using a devise gem and solved it. Most likely it was a problem with dependencies.

Unfortunately I don't know what exactly was wrong, because I just uninstalled all that might cause any influence to my Ruby installation and its gems dependencies and reinstalled all.

First I deleted my trial application to further recreate it with proper environment.

Then I followed this guide to prepare clean Ubuntu for Ruby installation and for installing Ruby itself (starting from removing Ubuntu's old rvm and ruby).

Here is a guide for installing rails, but it was enough to just gem install rails.

To recreate my trial app with fresh Ruby on Rails environment I was still following this guide (same as in question).

This time command:

rails g devise:install

worked perfectly.

Also I haven't got any problems with further guide instructions.

这篇关于Rails4和Devise(NoMethod错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆