Reloading problem in development

Hi Robbie!

Hi Robbie:

(last message got cut off somehow.)

Can you try to upgrade from 1.2.3 to 1.2.6 and run your tests? 1.2.6 posts lots of deprecation warnings and is meant to be a transitional version. You might find something useful there.

I suspect that the load-paths thing you’re doing is causing the problem. The first thing I’d do is explicitly add each model subfolder instead of * and see if that works. If it does, then perhaps this patch addresses it.

http://github.com/rails/rails/commit/cce30f71246dbc5433153156afa4f952553ad13d

I don’t typically do this in my models folder - I’m pretty content with a flat folder structure, even with +100 models.

Brian Hogan wrote:

Hi Robbie:

Hi Brian. I hope you are doing well.

(last message got cut off somehow.)

Can you try to upgrade from 1.2.3 to 1.2.6 and run your tests? 1.2.6
posts lots of deprecation warnings and is meant to be a transitional version.
You might find something useful there.

Just tried that and no errors. It worked fine, just like 1.2.3.

I suspect that the load-paths thing you're doing is causing the problem.

That is the suggested solution if you have models in subdirectories.

The first thing I'd do is explicitly add each model subfolder instead of *
and see if that works. If it does, then perhaps this patch addresses it.

Tried it, no difference.

http://github.com/rails/rails/commit/cce30f71246dbc5433153156afa4f952553ad13d

I applied it, but it started complaining. It looks like other patches
are required before applying that patch.

I don't typically do this in my models folder - I'm pretty content with
a flat folder structure, even with +100 models.

I have 232 models and counting. It is a rather large app that is
naturally hierarchical and using subdirectories made logical sense.
Unfortunately Rails doesn't handle it very well.

Any other suggestions? :slight_smile:

Regards,
Robbie
http://statsheet.com

.

I don't typically do this in my models folder - I'm pretty content
with
a flat folder structure, even with +100 models.

I have 232 models and counting. It is a rather large app that is
naturally hierarchical and using subdirectories made logical sense.
Unfortunately Rails doesn't handle it very well.

Probably not relevant to the question at hand, but you can stick your
models in separate folders without namespacing them: http://blog.hasmanythrough.com/2008/5/6/a-simple-alternative-to-namespaced-models

Fred

Here is a simple example of what I'm talking about.

My first example uses Rails 1.2.6:

script/console
Loading development environment.

conf.return_format = ""
cs = Ball::CoachSeason.find(:first)
puts cs.coach.full_name

David Aaron

reload!

Reloading...

cs = Ball::CoachSeason.find(:first)
puts cs.coach.full_name

David Aaron

Second example uses 2.1.0:

script/console
Loading development environment (Rails 2.1.0)

conf.return_format = ""
cs = Ball::CoachSeason.find(:first)
puts cs.coach.full_name

David Aaron

reload!

Reloading...

cs = Ball::CoachSeason.find(:first)
puts cs.coach.full_name

NoMethodError: undefined method `full_name' for
#<Ball::Coach:0x2ab4ce75fbe0>
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:256:in
`method_missing'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/associations/association_proxy.rb:177:in
`send'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/associations/association_proxy.rb:177:in
`method_missing'
  from (irb):7

Here is a simple example of what I'm talking about.

Anything interesting in the models ? Have you been able to construct a
small app from scratch that exhibits the problem ?

Fred

Ahhh! I didn’t see the namespacing that you’re doing. I recommend Fred’s suggestion. Namespacing of models seems to get broken a lot. I’ve done Rails for over 3 years now and it’s been broken at least twice before (that I remember). That doesn’t excuse it breaking of course.

Here’s an idea… can you run on edge and see it that fixes it?

Thanks to Fred and Brian's suggestions, I was able to track this down.
For some unknown reason I had put "include Ball" (using my previous
example) in lib/search.rb. After I removed it, the reload problem went
away.

Strange, but whatever :wink: I'm just glad it is fixed.