Giter Club home page Giter Club logo

Comments (8)

josevalim avatar josevalim commented on May 22, 2024

Devise relies on Rails require_dependency, which bundler does not use. require_dependency knows that Devise::Controllers::Filters is available at "devise/controllers/filter" and loads that file automatically. Using bundler, that file cannot be loaded and should be required manually.

from devise.

josevalim avatar josevalim commented on May 22, 2024

After a talk with Yehuda, we agreed that the bundler preinitializer for Rails 2.3 needs to be improved, something along those lines might make it work:

require "#{File.dirname(__FILE__)}/../vendor/bundler_gems/environment"

Gem.loaded_specs.values.each do |spec|
  require_dependency File.expand_path("lib", spec.full_gem_path)
  init = File.expand_path("init", spec.full_gem_path)
  require init if File.exists?(init)
end

from devise.

deepj avatar deepj commented on May 22, 2024

I've tried the code and it failed on:

c:\dev\MUNI\Bakalarka\portfonica>ruby script\server
c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:6:in `block in ': undefined method `require_dependency' for main:Object (NoMethodError)
        from c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:5:in `each'
        from c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:5:in `'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:28:in `load'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:28:in `preinitialize'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:10:in `boot!'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:110:in `'
        from script/server:2:in `require'
        from script/server:2:in `'

from devise.

josevalim avatar josevalim commented on May 22, 2024

Hrm, so try it at the end of config/environment.rb.

from devise.

deepj avatar deepj commented on May 22, 2024

It has not helped, it returns the same problem like in my first report.

But It is okay. It seems to be a problem in Bundler, so sorry for reporting here :).

from devise.

josevalim avatar josevalim commented on May 22, 2024

No problem. Just one more try. Instead of "require_dependency" try "ActiveSupport::Dependencies.require_dependency" or simple adding it to load path "ActiveSupport::Dependencies.load_path <<".

from devise.

pacoguzman avatar pacoguzman commented on May 22, 2024

Hi!

I'm in the same problem, my configuration is the following:
boot.rb (at the end) # To run with passenger

class Rails::Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end

def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
define_method(:load_environment) do
Bundler.require_env RAILS_ENV
old_load.bind(self).call
end
end
end
end

preinitializer.rb

require "#{RAILS_ROOT}/vendor/bundled_gems/environment"

And I'm tried all your options but nothings happens, I've received the following errror:

undefined method devise' for #<Class:0x7fb972d37448> /home/pacoguzman/dev/my_github/tmp/devise/vendor/bundled_gems/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:inmethod_missing'
/home/pacoguzman/dev/my_github/tmp/devise/app/models/user.rb:2

Thanks

from devise.

josevalim avatar josevalim commented on May 22, 2024

I just noticed the code above was wrong, here is the proper version:

require "#{File.dirname(FILE)}/../vendor/bundler_gems/environment"

Gem.loaded_specs.values.each do |spec|
require_dependency File.expand_path("lib", spec.full_gem_path)
init = File.expand_path("init", spec.full_gem_path)
require init if File.exists?("#{init}.rb")
end

If this does not work, try doing require "devise" in your initializer/preinitializer. If that does not work, I do not know how to help any longer. This is more a bundler issue though.

from devise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.