2

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?

Community
  • 1
  • 1
Sergey Makhonin
  • 350
  • 3
  • 13
  • Have you tried `bundle:install`? Looks like Devise has problems connecting to a super Class or something – Richard Peck Jul 15 '14 at 09:21
  • When I do anything including `rails generate` I am getting this error. But when I do `bundle install` it shows proper gems list. But has no effect indeed. – Sergey Makhonin Jul 15 '14 at 10:44

1 Answers1

0

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.

Sergey Makhonin
  • 350
  • 3
  • 13