Rick Denatale wrote: > > Basic Ruby lesson. > > You have > > class SampleLog::SamplesController << .... > > def home > @samples = Sample.find :all > end > end > > When Ruby needs to figure out what Sample means in that home action, > it first looks for a constant in the current namespace so it looks for > > SampleLog::SamplesController::Sample > > Rails catches this as a missing constant and tries to find a file > under one of the load paths sample_log/samples_controller/sample.rb > but doesn't find one > so it hands the problem back to Ruby, which then tries to find the > constant Sample one step up the namespace chain and looks for > SampleLog::Sample. > Now rails looks for sample_log/sample.rb and finds it, and loads it, > and then checks to see whether SampleLog::Sample is now defined, which > it isn't because that file defined ::Sample instead.
Rails is looking for ::Sample, not SampleLog::Sample (or so I would assume). If it finds (and loads) sample_log/sample.rb then all would be well. The problem seems to be that it is trying to be too clever. It finds the file, which defines the right class (::Sample), but decides that that file should be defining something else. > > Did you try just moving app/models/sample_log/sample.rb to > app/models/sample.rb as I suggested, I'm pretty sure that doing this, > and possibly removing the the stuff you did to monkey with the load > paths behind Rails back should fix your problem. > I am sure this will work. This is where I started from. It does not keep my models organised though! -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.