From: Josh Cheek Date: 2010-03-30T22:15:29+09:00 Subject: Re: Using of module and "Is not missing constant" error --000e0cd1ad1c14b8cd0483046cc4 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Mar 30, 2010 at 5:47 AM, Benoit Molenda wrote: > Brian Candler wrote: > > Benoit Molenda wrote: > >> Josh Cheek wrote: > >>> Classes and modules are constants, so their names need to begin with > >>> Uppercase Letters. > >> > >> Yes, sorry for my exemple, my real code follow of course the naming > >> style. > > > > So show a real piece of Ruby code which replicates the problem - > > something we can paste into a file and run for ourselves. > > > > Often, in boiling down a problem into a simple test case like that, > > you'll discover what the problem is. And if you don't, you will have > > made it much easier for others to determine what the problem is. > Sure. > > I create a test app with this code. > In app/controller/local/class_generator_controller.rb : > > class Local::VerticalGeneratorController < ApplicationController > def index > @models = VerticalBuilder::Vertical.list > @models = VerticalBuilder::Vertical.list #second call raise an > exception > end > end > > In lib/local/vertical_builder/vertical.rb : > module Local > module VerticalBuilder > class Vertical > def self.list > [] > end > end > end > end > > I get the same error when I call > http://localhost:3000/local/vertical_generator : > Local is not missing constant VerticalBuilder! > It seams that Ruby try to load each time the Constant instead of look > into already loaded... > -- > Posted via http://www.ruby-forum.com/. > > I think this is going to be a Rails question about how Rails handles loading files / environments. But a few thoughts to look at: What happens if you say Local::VerticalBuilder::Vertical.list ? What happens if you run your server in production mode? What happens if you place the code into an initializer instead of lib? --000e0cd1ad1c14b8cd0483046cc4--