Forum: Rails Engines Is engines broken in Rails 1.2.3?

Posted by Steve Koppelman (hatless)
on 2007-07-27 22: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.
Posted by Steve Koppelman (hatless)
on 2007-07-30 16: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 Koppelman 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.
...
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.