uninitialized constant Devise (NameError) #532

Closed
newstler opened this Issue Sep 27, 2010 · 2 comments

Comments

Projects
None yet
2 participants
@newstler

Hello,

I'm trying to make an engine with Devise inside it, basing on instructions found at http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/

That's my first Rails Engine, so I don't know what I'm doing wrong. But when I'm starting server or console of the app, into which I've added my engine, I get this error:

rails c
/usr/local/src/basic-set/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:200:in `each'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:200:in `block in <class:Engine>'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `run'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `each'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:134:in `initialize!'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:77:in `method_missing'
from /usr/local/src/meduzz/config/environment.rb:5:in `<top (required)>'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:103:in `require'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:103:in `require_environment!'
from /Users/yurisidorov/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

basic-set is the name of the engine, which is added to the main app as a gem.. If I'm running it as a standalone app everithing works just fine. Please, tell me what the wright way of making engines (mountable apps) from the working apps. Thank you a lot.

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Sep 27, 2010

Member

Probably when you are not running it stand-alone, Devise is not being required.

Member

josevalim commented Sep 27, 2010

Probably when you are not running it stand-alone, Devise is not being required.

@newstler

This comment has been minimized.

Show comment Hide comment
@newstler

newstler Sep 27, 2010

I've got this gemspec created by jeweler:

# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
  s.name = %q{basicset}
  s.version = "0.0.0"

  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  s.authors = ["Newstler"]
  s.date = %q{2010-09-27}
  s.extra_rdoc_files = [
    "README"
  ]
  s.files = [
    "app/controllers/application_controller.rb",
     "app/controllers/categories_controller.rb",
     "app/controllers/confirmations_controller.rb",
     "app/controllers/friendships_controller.rb",
     "app/controllers/passwords_controller.rb",
     "app/controllers/registrations_controller.rb",
     "app/controllers/roles_controller.rb",
     "app/controllers/sessions_controller.rb",
     "app/controllers/unlocks_controller.rb",
     "app/controllers/users_controller.rb",
     "app/helpers/application_helper.rb",
     "app/helpers/categories_helper.rb",
     "app/helpers/friendships_helper.rb",
     "app/helpers/roles_helper.rb",
     "app/helpers/users_helper.rb",
     "app/models/ability.rb",
     "app/models/category.rb",
     "app/models/friendship.rb",
     "app/models/role.rb",
     "app/models/user.rb",
     "app/views/categories/_form.html.erb",
     "app/views/categories/edit.html.erb",
     "app/views/categories/index.html.erb",
     "app/views/categories/new.html.erb",
     "app/views/categories/show.html.erb",
     "app/views/devise/confirmations/new.html.erb",
     "app/views/devise/mailer/confirmation_instructions.html.erb",
     "app/views/devise/mailer/reset_password_instructions.html.erb",
     "app/views/devise/mailer/unlock_instructions.html.erb",
     "app/views/devise/passwords/edit.html.erb",
     "app/views/devise/passwords/new.html.erb",
     "app/views/devise/shared/_links.erb",
     "app/views/devise/unlocks/new.html.erb",
     "app/views/friendships/_form.html.erb",
     "app/views/friendships/edit.html.erb",
     "app/views/friendships/index.html.erb",
     "app/views/friendships/new.html.erb",
     "app/views/friendships/show.html.erb",
     "app/views/layouts/_notice.html.erb",
     "app/views/layouts/_page.html.erb",
     "app/views/layouts/application.html.erb",
     "app/views/registrations/edit.html.erb",
     "app/views/registrations/new.html.erb",
     "app/views/roles/_form.html.erb",
     "app/views/roles/edit.html.erb",
     "app/views/roles/index.html.erb",
     "app/views/roles/new.html.erb",
     "app/views/roles/show.html.erb",
     "app/views/sessions/new.html.erb",
     "app/views/users/_form.html.erb",
     "app/views/users/_user_password.html.erb",
     "app/views/users/edit.html.erb",
     "app/views/users/index.html.erb",
     "app/views/users/new.html.erb",
     "app/views/users/show.html.erb",
     "app/views/users/user_password.js.rjs",
     "config/application.rb",
     "config/boot.rb",
     "config/database.yml",
     "config/environment.rb",
     "config/environments/development.rb",
     "config/environments/production.rb",
     "config/environments/test.rb",
     "config/initializers/backtrace_silencers.rb",
     "config/initializers/devise.rb",
     "config/initializers/inflections.rb",
     "config/initializers/mime_types.rb",
     "config/initializers/secret_token.rb",
     "config/initializers/session_store.rb",
     "config/initializers/unicode.rb",
     "config/locales/devise.en.yml",
     "config/locales/en.yml",
     "config/locales/ru.yml",
     "config/routes.rb",
     "lib/basicset.rb",
     "lib/basicset/engine.rb"
  ]
  s.rdoc_options = ["--charset=UTF-8"]
  s.require_paths = ["lib"]
  s.rubygems_version = %q{1.3.7}
  s.summary = %q{57 Engines Basic Set Engine for new apps}

  if s.respond_to? :specification_version then
    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
    s.specification_version = 3

    if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
      s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
      s.add_runtime_dependency(%q<unicode>, [">= 0"])
      s.add_runtime_dependency(%q<mysql2>, [">= 0"])
      s.add_runtime_dependency(%q<meta-tags>, [">= 0"])
      s.add_runtime_dependency(%q<devise>, [">= 1.1.2"])
      s.add_runtime_dependency(%q<cancan>, [">= 0"])
      s.add_runtime_dependency(%q<r18n-rails>, [">= 0"])
      s.add_runtime_dependency(%q<friendly_id>, ["~> 3.1"])
      s.add_runtime_dependency(%q<acts_as_list>, [">= 0"])
    else
      s.add_dependency(%q<rails>, [">= 3.0.0"])
      s.add_dependency(%q<unicode>, [">= 0"])
      s.add_dependency(%q<mysql2>, [">= 0"])
      s.add_dependency(%q<meta-tags>, [">= 0"])
      s.add_dependency(%q<devise>, [">= 1.1.2"])
      s.add_dependency(%q<cancan>, [">= 0"])
      s.add_dependency(%q<r18n-rails>, [">= 0"])
      s.add_dependency(%q<friendly_id>, ["~> 3.1"])
      s.add_dependency(%q<acts_as_list>, [">= 0"])
    end
  else
    s.add_dependency(%q<rails>, [">= 3.0.0"])
    s.add_dependency(%q<unicode>, [">= 0"])
    s.add_dependency(%q<mysql2>, [">= 0"])
    s.add_dependency(%q<meta-tags>, [">= 0"])
    s.add_dependency(%q<devise>, [">= 1.1.2"])
    s.add_dependency(%q<cancan>, [">= 0"])
    s.add_dependency(%q<r18n-rails>, [">= 0"])
    s.add_dependency(%q<friendly_id>, ["~> 3.1"])
    s.add_dependency(%q<acts_as_list>, [">= 0"])
  end
end

as I see it requires all dependecies to Devise...

I've got this gemspec created by jeweler:

# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
  s.name = %q{basicset}
  s.version = "0.0.0"

  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  s.authors = ["Newstler"]
  s.date = %q{2010-09-27}
  s.extra_rdoc_files = [
    "README"
  ]
  s.files = [
    "app/controllers/application_controller.rb",
     "app/controllers/categories_controller.rb",
     "app/controllers/confirmations_controller.rb",
     "app/controllers/friendships_controller.rb",
     "app/controllers/passwords_controller.rb",
     "app/controllers/registrations_controller.rb",
     "app/controllers/roles_controller.rb",
     "app/controllers/sessions_controller.rb",
     "app/controllers/unlocks_controller.rb",
     "app/controllers/users_controller.rb",
     "app/helpers/application_helper.rb",
     "app/helpers/categories_helper.rb",
     "app/helpers/friendships_helper.rb",
     "app/helpers/roles_helper.rb",
     "app/helpers/users_helper.rb",
     "app/models/ability.rb",
     "app/models/category.rb",
     "app/models/friendship.rb",
     "app/models/role.rb",
     "app/models/user.rb",
     "app/views/categories/_form.html.erb",
     "app/views/categories/edit.html.erb",
     "app/views/categories/index.html.erb",
     "app/views/categories/new.html.erb",
     "app/views/categories/show.html.erb",
     "app/views/devise/confirmations/new.html.erb",
     "app/views/devise/mailer/confirmation_instructions.html.erb",
     "app/views/devise/mailer/reset_password_instructions.html.erb",
     "app/views/devise/mailer/unlock_instructions.html.erb",
     "app/views/devise/passwords/edit.html.erb",
     "app/views/devise/passwords/new.html.erb",
     "app/views/devise/shared/_links.erb",
     "app/views/devise/unlocks/new.html.erb",
     "app/views/friendships/_form.html.erb",
     "app/views/friendships/edit.html.erb",
     "app/views/friendships/index.html.erb",
     "app/views/friendships/new.html.erb",
     "app/views/friendships/show.html.erb",
     "app/views/layouts/_notice.html.erb",
     "app/views/layouts/_page.html.erb",
     "app/views/layouts/application.html.erb",
     "app/views/registrations/edit.html.erb",
     "app/views/registrations/new.html.erb",
     "app/views/roles/_form.html.erb",
     "app/views/roles/edit.html.erb",
     "app/views/roles/index.html.erb",
     "app/views/roles/new.html.erb",
     "app/views/roles/show.html.erb",
     "app/views/sessions/new.html.erb",
     "app/views/users/_form.html.erb",
     "app/views/users/_user_password.html.erb",
     "app/views/users/edit.html.erb",
     "app/views/users/index.html.erb",
     "app/views/users/new.html.erb",
     "app/views/users/show.html.erb",
     "app/views/users/user_password.js.rjs",
     "config/application.rb",
     "config/boot.rb",
     "config/database.yml",
     "config/environment.rb",
     "config/environments/development.rb",
     "config/environments/production.rb",
     "config/environments/test.rb",
     "config/initializers/backtrace_silencers.rb",
     "config/initializers/devise.rb",
     "config/initializers/inflections.rb",
     "config/initializers/mime_types.rb",
     "config/initializers/secret_token.rb",
     "config/initializers/session_store.rb",
     "config/initializers/unicode.rb",
     "config/locales/devise.en.yml",
     "config/locales/en.yml",
     "config/locales/ru.yml",
     "config/routes.rb",
     "lib/basicset.rb",
     "lib/basicset/engine.rb"
  ]
  s.rdoc_options = ["--charset=UTF-8"]
  s.require_paths = ["lib"]
  s.rubygems_version = %q{1.3.7}
  s.summary = %q{57 Engines Basic Set Engine for new apps}

  if s.respond_to? :specification_version then
    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
    s.specification_version = 3

    if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
      s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
      s.add_runtime_dependency(%q<unicode>, [">= 0"])
      s.add_runtime_dependency(%q<mysql2>, [">= 0"])
      s.add_runtime_dependency(%q<meta-tags>, [">= 0"])
      s.add_runtime_dependency(%q<devise>, [">= 1.1.2"])
      s.add_runtime_dependency(%q<cancan>, [">= 0"])
      s.add_runtime_dependency(%q<r18n-rails>, [">= 0"])
      s.add_runtime_dependency(%q<friendly_id>, ["~> 3.1"])
      s.add_runtime_dependency(%q<acts_as_list>, [">= 0"])
    else
      s.add_dependency(%q<rails>, [">= 3.0.0"])
      s.add_dependency(%q<unicode>, [">= 0"])
      s.add_dependency(%q<mysql2>, [">= 0"])
      s.add_dependency(%q<meta-tags>, [">= 0"])
      s.add_dependency(%q<devise>, [">= 1.1.2"])
      s.add_dependency(%q<cancan>, [">= 0"])
      s.add_dependency(%q<r18n-rails>, [">= 0"])
      s.add_dependency(%q<friendly_id>, ["~> 3.1"])
      s.add_dependency(%q<acts_as_list>, [">= 0"])
    end
  else
    s.add_dependency(%q<rails>, [">= 3.0.0"])
    s.add_dependency(%q<unicode>, [">= 0"])
    s.add_dependency(%q<mysql2>, [">= 0"])
    s.add_dependency(%q<meta-tags>, [">= 0"])
    s.add_dependency(%q<devise>, [">= 1.1.2"])
    s.add_dependency(%q<cancan>, [">= 0"])
    s.add_dependency(%q<r18n-rails>, [">= 0"])
    s.add_dependency(%q<friendly_id>, ["~> 3.1"])
    s.add_dependency(%q<acts_as_list>, [">= 0"])
  end
end

as I see it requires all dependecies to Devise...

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment