Re: Unnecessary exception raised in AS::Dependencies.load_missing_constant

Yehuda Katz
2010-02-15T14:26:45Z

Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325


On Mon, Feb 15, 2010 at 6:15 AM, Andrew White <andyw@pixeltrix.co.uk>
wrote:

>
> On 15 Feb 2010, at 13:31, Yehuda Katz wrote:
>
> > I wouldn''t. I consider Rails'' lookup from disk to be
an alternate form of
> constant lookup, and I''d want it to use semantics that are
identical to
> Ruby''s semantics:
> >
> > class Foo::Bar
> >   Baz
> >   # normal Ruby: will search Foo::Bar::Baz and Object::Bar
> >   # rails: will search Foo::Bar::Baz, Foo::Baz, and Object::Baz
> > end
> >
> > This discrepancy means that the behavior could be different depending
on
> whether autoload is in effect (for instance, if all constants are
preloaded,
> and autoload is turned off, the behavior would be different than when it
was
> on). I''m not happy about that, and would remove the discrepancy if
possible.
>
> Following the Ruby semantics will mean that this will never work:
>
> class Admin::Account < ActiveRecord::Base
>  has_many :users
> end
>
> You''ll always have to specify the class on the association:
>
> class Admin::Account < ActiveRecord::Base
>  has_many :users, :class_name => "Admin::User"
> end
>
> My aesthetic sense rejects this as a solution :-)
>
> The alternative is to implement a custom constant lookup system within
> ActiveRecord which we probably don''t want to do.
>
>
Actually that''s precisely where it belongs. ActiveSupport::Dependencies
should mirror the Ruby logic exactly (in other words, it should be possible
to require all the files manually and have everything work). If
Admin::Account has_many :users needs to be able to pull Admin::User,
ActiveRecord should know how to do that.


>
> Andrew White
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
>
rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.