Engines for Rails 2.0

Hi everybody,

I’m highly interested in getting a working Engines setup running on
Rails 2.0 as soon as possible. I have convinced a customer to use
Engines to slice up a huge Rails app but he wants it to run Rails 2.0

I already mailed with Josh F. who wrote the “initial hack”
posted here: http://dev.rails-engines.org/engines-plugin/tickets/267
and he kindly send me his entire Engines plugin directory.

I can’t seem to get it working though at all. Basically I’ve set up a
fresh Rails app and added the Engines::PluginLoader like given in the
ticket above. In environment.rb I added below the boot.rb require line:

require File.join(File.dirname(FILE), ‘…/vendor/plugins/engines/
lib/engines/plugin_loader’)

And in vendor/plugins/engines/lib/engines/rails_extensions/rails.rb at
the top:

require ‘active_support’

Mongrel will then die with the error:

vendor/rails/railties/lib/initializer.rb:193:in `initialize’: wrong
number of arguments (1 for 2) (ArgumentError)

Not sure what’s wrong here. Looking at the #initialize method of the
Engines::PluginLoader that fails here this very much looks like the
#initialize method of the Engines Plugin class.

Can anybody help me out with this? Probably someone has running Rails
2.0 application set up with Engines and can zip me up the whole
application as a starting point?

I’m eager to get something up and running by Wednesday evening because
I want to present it to a customer who wants to slice up a huge Rails
app and Engines seems to be the perfect choice for that. It has to
work with Rails 2.0 though.

Also … I’d be interested in learning if there’s any work in progress
for an official version of Engines for Rails 2.0.

Thanks a lot for any pointers!


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

Ok, after quite some reading through the Rails 2.0 plugin load process
I’ve been able to come up with my own stab at this now.

See this patch: Parked at Loopia and the top portion of
environment.rb here: Parked at Loopia

I’ve added a PluginLocator (extending the
Rails::Plugin::FileSystemLocator) instead of a PluginLoader because
that’s the class that is responsible for finding and instantiating
plugins in Rails 2.0

Also I’ve changed the Engines Plugin class to extend the Rails::Plugin
class.

I’ve tried this with Gwyn Morfey’s Macaque engine and it exports the
migrations with script/generate plugin_migration. Also Mongrel starts
up and I can access the MacaqueController with the appropriate views
etc.

I’m still super-curious about what’s necessary to get an official
Engines version for Rails 2.0 going.

Thanks!

Am 20.11.2007 um 14:15 schrieb Sven F.:

I can’t seem to get it working though at all. Basically I’ve set up a
require ‘active_support’
Can anybody help me out with this? Probably someone has running Rails


Engine-Users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

On 11/20/07, Sven F. [email protected] wrote:

See this patch: Parked at Loopia and the top portion of
environment.rb here: Parked at Loopia

Hi Sven,

Thanks for these patches - I’m definitely keen to get a Rails 2.0
compatible version of the engines plugin released as soon as possible.
Until recently I was holding out for some changes to the internal
mechanisms used by Rails to load plugins
(http://dev.rubyonrails.org/changeset/8115), but now that those
changes have been accepted I hope to fix up the engines plugin soon.

Since Rails’ own “native” plugin loading mechanism has now caught up
with some of the enhancements that the engines plugin used to provide
(a proper plugin model, loading all remaining plugins with :all, etc)
I’m keen to trim down the changes that the engines plugin makes so
that the plugin stays as lightweight as possible.

If you’re keen to contribute, any investigations as to which parts of
the existing codebase (along with your Pastie’d patches) would be
greatly appreciated!

Thanks again,

James

Hi James,

I’ve now managed to look through the codebase.

Basically I’d like to start refactoring from my patch and successively
remove duplicate functionality.

I’m not sure if it makes sense to partition this up (you asked for
investigations as to which parts of the codebase I’d want to touch).
As far as I can see there’s:

  • the Engines’ plugin class could probably be replaced by a module
    that would be mixed into the Rails::Plugin class
  • some of the Engine module could probably moved to
    Rails::Plugin::Loader or to a Engine::PluginLoader that extends from
    the latter
  • a dedicated Engine::PluginLocator might be superflous then because
    the Rails::Plugin class would be used and Rails::Plugin::Loader seems
    to keep track of the plugin instances (is it accessible though?)
  • Engines::RailsExtensions::RailsInitializer could be removed (it
    already is in my patch)

These might be fine as they are:

Engines::PluginMigrator
Engines::RailsExtensions::ActiveRecord
Engines::RailsExtensions::Dependencies
Engines::RailsExtensions::Migrations
Engines::RailsExtensions::PublicAssetHelpers
Engines::RailsExtensions::Templates

I’ve also looked for test suites in the repository. There seem to be
several applications for testing different Rails versions. The “rails
edge” application doesn’t seem to have any engines installed, the
tests seem to rely on them though (“alpha_engine” etc.). Am I missing
something obvious?

Am 20.11.2007 um 18:54 schrieb James A.:

(http://dev.rubyonrails.org/changeset/8115), but now that those
greatly appreciated!
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

Hi James,

thanks for your quick reply!

Am 20.11.2007 um 18:54 schrieb James A.:

Thanks for these patches - I’m definitely keen to get a Rails 2.0
compatible version of the engines plugin released as soon as possible.

This sentence just lifted a ton of weight off my mind :slight_smile:

Until recently I was holding out for some changes to the internal
mechanisms used by Rails to load plugins
(http://dev.rubyonrails.org/changeset/8115), but now that those
changes have been accepted I hope to fix up the engines plugin soon.

This stuff is already in Rails 2.0 RC1, isn’t it? Because in
http://dev.rubyonrails.org/ticket/9795
you say that you’ve added a class Rails::Plugin and I’ve already
seen this one (and even extended it in that patch). Ok, I think I’ll
go and read that stuff up.

Since Rails’ own “native” plugin loading mechanism has now caught up
with some of the enhancements that the engines plugin used to provide
(a proper plugin model, loading all remaining plugins with :all, etc)
I’m keen to trim down the changes that the engines plugin makes so
that the plugin stays as lightweight as possible.

Yes, I already wanted to ask about that. Looks like quite some stuff
could be dropped from Engines.

If you’re keen to contribute, any investigations as to which parts of
the existing codebase (along with your Pastie’d patches) would be
greatly appreciated!

I haven’t used Engines so far and don’t even know all of its features :slight_smile:

That said, I would be happy to contribute as I’m both personally and
professionally interested in this approach.

I guess I’ll just spend some more time on reading the codebase and
then report back.

Do you have any suggestions?


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

Hi,

Did you get anywhere with this? I’d be interested in helping out
assembling
an Engines plugin for 2.0

Sven, have you tackled the javascript and css file aggregation/caching
stuff?

eg:   javascript_include_tag(:all, :cache => true)  (from DHH's 2.0

release blurb)

That’s one of the most exciting features of 2.0 for me, as virtually
every engine I’ve written has one (or more!) .js files. I didn’t see
any code (or tests) looking at that feature yet. But I’m not much of an
engines core hacker yet… :slight_smile:

Again, thanks for the work on this!

-Rob

Hi Rob,

nope.

The first goal is to get Rails Engines working on Rails 2.0 with the
functionality it already has on Rails 1.2. This requires some quite
extensive refactoring as Rails 2.0 has adopted some of the internal
means for plugin loading etc. that Rails Engines provided for Rails
1.2. (Rails Engines for Rails 2.0 will build on this infrastructure
and therefor will be much more lightweight.)

That said, I’d also love to see that feature in Rails Engines :slight_smile:

Am 07.12.2007 um 22:11 schrieb Rob M.:

yes, this thread has been continued on the engine-developers list

That said, all the other tests are passing, i.e. the basic
Am 07.12.2007 um 20:29 schrieb Tony A.:

  • the Engines’ plugin class could probably be replaced by a module

several applications for testing different Rails versions. The
Engine-Users mailing list


Engine-Users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org


Engine-Developers mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

Hi Tony,

yes, this thread has been continued on the engine-developers list (you
might want to register there, if you are not, and have a glance the
archives).

The code has been checked in to the Rails Engines repository here:
http://svn.rails-engines.org/test/engines/rails_2.0/

(This is a complete Rails app in order to get testing going.)

Currently there are two tests failing:

Arbitrary code mixing: the test on line 34 in
http://dev.rails-engines.org/repository/file/test/engines/rails_2.0/test/unit/arbitrary_code_mixing_test.rb

Model/Lib loading precedence:
http://dev.rails-engines.org/repository/file/test/engines/rails_2.0/test/unit/model_and_lib_test.rb
(ignore the note about functional/view_loading_test.rb in there)

Also, the ActionMailer seems to have changed in Rails 2.0 and this
part of Engines is currently just deactivated.

That said, all the other tests are passing, i.e. the basic
functionality (like model/view/controller loading, routes, migrations
etc.) already seems to work. (I also have it being used at a client of
mine for test purposes and there haven’t been any problems with the
basic stuff.)

If you want to get involved with helping here, … I guess that’s
appreciated as everybody seems to be pretty busy these days.

Am 07.12.2007 um 20:29 schrieb Tony A.:

Rails::Plugin::Loader or to a Engine::PluginLoader that extends from
Engines::RailsExtensions::ActiveRecord


Tony A.
ClickCaster, Inc.
[email protected] _______________________________________________
Engine-Users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org


sven fuchs [email protected]
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)

Hey…

Checkout the toolbawks_packer plugin I wrote up. It allows you to do
just
that bug even better. Planning on moving more towards a bundle_fu
approach
with a block wrapper, but right now it works awesome for me. Beta
software
so far, but will do the trick never the less :slight_smile:

Also, I have dropped in bundle_fu in existing apps as well, and it works
pretty decently as well.

With that said, we don’t really need it in Engines directly per-say, as
additional options are available, but nice if it was there. Although
Rails
2.0 doesn’t really do the job that well, or at least as well as the
toolbawks_packer and bundle_fu plugins do.

Nathaniel.