On Thu, May 6, 2010 at 6:58 AM, Andy Joel <[email protected]> wrote: > I have my models and controllers set up in sub-folders, so, for example, > sample.rb is in app/models/sample_log, and samples_controller.rb is in > app/controllers/sample_log. The controllers are defined to be within a > namespace just though the class name, eg like this: > > class SampleLog::SamplesController < SampleLog::SuperController > > However, the models are not. > > class Sample < ActiveRecord::Base
Where is this file? I'm guessing that it's in app/models/sample_log/sample.rb ? > Instead, I have added the relevant directories to config.load_paths in > environment.rb. Which may be part of the problem. You might well be fighting convention over configuration. > Unit testing, functional testing and integration testing > all pass without a problem, and I can use the Rails console normally > too. > > However, trying to access the web pages leads to some problems... > > Putting a print statement in sample.rb, I can see that it is only when I > try to access a page with a sample on it that sample.rb gets loaded, > which makes perfect sense. However, it then throws an error: > > Expected R:/samplelog/app/models/sample_log/sample.rb to define > SampleLog::Sample What this is saying is that Rails tried to find a class or module SampleLog::Sample What rails does here is to look for samplelog/sample.rb somewhere in the various load paths. It's finding app/models/sample_log/sample.rb which if it indeed contains: class Sample < ActiveRecord::Base outside of a class or module block is definining ::Sample, not ::SampleLog::Sample. I'm guessing that moving app/models/sample_log/sample.rb to app/models/sample.rb will fix this. If not then show us the walkback you get on the error, it should point to some piece of code which is referring to some constant (name_space::)*Sample -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

