ruby on rails - Cannot require file in application.rb -
i'm trying simplify our configuration creating little configuration classes can included in our application.rb.
lib/logging.rb
class << logging def configure(config) # ... configure logging stuff end end
application.rb
require 'lib' module myapp class application < rails::application logging.configure(config) end end
the problem if don't utilize require "lib"
undefined constant logging
error. if seek require get:
bin/rails:6: warning: initialized constant app_path /opt/qtip/bin/rails:6: warning: previous definition of app_path here
the way i've been able work doing limiting.
config.autoload_paths = %w(lib) config.after_initialize ::logging.configure(config) end
you have wrong class declaration.
instead
class << logging
you should use
class logging class << self def configure(config) end end end
ruby-on-rails ruby
No comments:
Post a Comment