Forum: Rails Engines Is engines broken in Rails 1.2.3?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Steve K. (Guest)
on 2007-07-28 00:31
A few hours ago I factored out one of my AR models that I'd be reusing
into a minimalist plugin. I copied the model into the plugin's lib/,
added a line to init.rb to load it, and the model was now present in the
console.

The next step was to move the model's controller and views into the
plugin. Engines seemed like the way to go, since that's exactly what
it's for. So I install the Engines plugin per the site's instructions.

I follow Gwyn's tutorial step by step: I create an app/ hierarchy at the
top level of my plugin, I empty out my init.rb because that's what he
does in Macaque. I move my model into the plugin's app/models. I restart
my console and I get this:

>> Geo.find(1)
LoadError: Expected ./script/../config/../config/../app/models/geo.rb to
define
Geo
        from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
/active_support/dependencies.rb:249:in `load_missing_constant'
        from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
/active_support/dependencies.rb:452:in `const_missing'
        from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
/active_support/dependencies.rb:464:in `const_missing'
        from (irb):3
>>

I can get at all my other (non-plugin) classes just fine, but this one?
No dice. Both Engines and my plugin show up in Rails.plugins, and the
output shows that it's being seen as an engine in that it has model,
controller and view paths. My development log shows the engines plugin
loading first and this and my other plugins loading with engines
extensions.

I know Engines is broken in Edge, but is it also broken in the current
1.2.3 release? If it isn't, I'll be glad to dig deeper and paste in my
plugin's whole directory and file layout, etc.
Steve K. (Guest)
on 2007-07-30 18:11
Solved it myself. I had to delete my app's app/models/geo.rb from the
filesystem even though I had the entire contents commented out. Rails
was probably loading it after my engine's version, wiping out the
definition.

Steve K. wrote:
...
> I follow Gwyn's tutorial step by step: I create an app/ hierarchy at the
> top level of my plugin, I empty out my init.rb because that's what he
> does in Macaque. I move my model into the plugin's app/models. I restart
> my console and I get this:
>
>>> Geo.find(1)
> LoadError: Expected ./script/../config/../config/../app/models/geo.rb to
> define
> Geo
>         from
> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
> /active_support/dependencies.rb:249:in `load_missing_constant'
>         from
> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
> /active_support/dependencies.rb:452:in `const_missing'
>         from
> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib
> /active_support/dependencies.rb:464:in `const_missing'
>         from (irb):3
>>>
>
> I can get at all my other (non-plugin) classes just fine, but this one?
> No dice. Both Engines and my plugin show up in Rails.plugins, and the
> output shows that it's being seen as an engine in that it has model,
> controller and view paths. My development log shows the engines plugin
> loading first and this and my other plugins loading with engines
> extensions.
...
This topic is locked and can not be replied to.