New to Rails & Engines - Need help with 1.2 branch

Hi, I’m currently working a school project using Rails to build a web
application.
After looking at various plugins, our team has decided to go with
Engines to allow re-use of some components of our application.

Since Rails 1.2 has just been released, we figured we might as well
start developing with the latest version. We had tried some small
engines using Engines 1.1.4 following the tutorial on ALTERthought
Blogs and there was no problem.

With Engines 1.2, however, I’m having a hard time creating a new
engine. Would it be possible to post a small tutorial outlining the
steps to creating a simple engine using the 1.2 branch?

Here’s how I proceeded:

  1. Created a new Rails project with dummy model & scaffold.
  2. Installed the Engines plugin through the command:
    ruby script/plugin install
    http://svn.rails-engines.org/engines/branches/rb_1.2/
  3. Tried to build my engine using the engine generator:
    ruby script/generate engine MyEngine

This step gives me the following error message:


ruby script/generate engine MyEngine
./script/…/config/boot.rb:29:Warning: require_gem is obsolete. Use gem
instead
.
D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependenci
es.rb:377:in new_constants_in': You have a nil object when you didn't expect it ! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.empty? from D:/ruby/lib/ruby/gems/1.8/g ems/activesupport-1.4.0/lib/active_support/dependencies.rb:203:in load_file’
from
D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo
rt/dependencies.rb:95:in require_or_load' from D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo rt/dependencies.rb:249:in load_missing_constant’
from
D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo
rt/dependencies.rb:453:in const_missing' from ./script/../config/../vendor/plugins/rb_1.2/lib/engines/rails_exten sions/rails_initializer.rb:23 from D:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in ge
m_original_require’
from
D:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in re quire' from D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo rt/dependencies.rb:496:in require’
… 21 levels…
from
D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo
rt/dependencies.rb:496:in require' from D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo rt/dependencies.rb:343:in new_constants_in’
from
D:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_suppo
rt/dependencies.rb:496:in `require’
from script/generate:3


It’s probably a very trivial mistake on my part, but I would really
appreciate if someone could point me in the right direction. My
apologies if this email is being posted in the wrong forum / mailing
list.

Thanks.

Steve

Hi Steve,

There are two things going on here

On 1/27/07, Steve [email protected] wrote:

  1. Tried to build my engine using the engine generator:
    ruby script/generate engine MyEngine

With the 1.2 release of the engines plugin, you no longer generate ‘an
engine’, since there is no such thing anymore. Instead, create a
plugin as normal, except with app/, db/migrate, and so on as required.

I’d recommend creating plugins by hand since there’s nothing much to
them (init.rb and lib, basically, everything else is additional), but
you could use the plugin generator if needs be.

I’m not sure where the source of actual exception is coming from,
since the ‘engine’ generator doesn’t exist anymore - do you have an
old copy of the plugin installed?

I’d recommend creating plugins by hand since there’s nothing much to
them (init.rb and lib, basically, everything else is additional), but
you could use the plugin generator if needs be.

Why can’t we have a generator anymore? It still seems like a good idea
if just to show people what a good structure is anymore. If nothing it
sets up the testing directory which the plugin generator doesn’t have
at all.

The engine generator was one of the biggest draws for me.

Goes and installs an old version just for the generator

On 2/24/07, Chuck V. [email protected] wrote:

Why can’t we have a generator anymore? It still seems like a good idea
if just to show people what a good structure is anymore. If nothing it
sets up the testing directory which the plugin generator doesn’t have
at all.

While I like that rails (and the old generator) prompts you to test by
producing a test directory, this can’t be the only thing that
convinces you that you need to write some tests. More often than not,
the test directory (and the others: public, db/migrate, etc) would
just be ignored if they were unwanted.

This is why I dropped the generator - too often we’d end up with
plugins that had a public/ directory tree that was completely empty,
or a functional tests directory that just wasn’t relevant, but was
hanging around regardless. This is one of the reasons that “engines”
were perceived as heavyweight, and I doubt anyone can have avoided my
“engines are dead, we’re all just lightweight plugins now”
near-ranting.

I guess ultimately I feel that the generator helped too much, to the
detriment of the project. I’m sorry that you are feeling its absence,
but creating only the directories that you need isn’t too bad is it?