Rails: Same name for a library module and a group of controllers? -


i'm in process of organizing code, far have managed groupcontrollers/helpers/views in folders "admin", used have library same module name "admin" i'm not being able call anymore. (name conflict?)

the new structure:

directory structure   -> app     -> controllers        -> admin #new         -> admin_main         -> admin_permissions      -> helpers       -> admin #new         -> admin_main_helper         -> admin_permissions_helper    -> lib     -> admin       -> pagerduty.rb 

i used able call library helpers this:

module admin::adminmainhelper #admin:: new   require "./lib/admin/pagerduty.rb"    def pager_duty     pagerduty = admin::pagerduty.new() #throws error after new structure     @on_call = pagerduty.first_on_call()     @counts = pagerduty.open_incidents()   end  end 

the error "uninitialized constant admin::pagerduty"

do have rename library else? or there way around this?

edit: works if rename library module "adminlib" instead of "admin" example. question if there way around this.

i think problem lies load path. think require should be:

require "#{rails.root}/lib/admin/pagerduty.rb" 

another solution, albeit little heavy handed, load of lib subdirectories in load_path, eg:

in application.rb config.autoload_path:

config.autoload_paths += dir["#{config.root}/lib/**/"] 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -