Rails3 Plugin Guide init.rb confusion

This has two things that doesn’t make sense to me.

  1. it advocates a Rails folder with it’s own init.rb in it. AFAICT
    that’s an old idiom that no longer applies to Rails 3, but I can’t seem
    to find a definitive confirmation on that.

  2. it advocates that /PLUGIN/init.rb should include
    /PLUGIN/lib/yaffle.rb as the one and only require statement and that
    yaffle.rb should be the file where all the needed require statements be
    written to “keep init.rb clean.”

I don’t understand the merit of that. How many require statements is not
clean? 20, 20, 5? If I have 2 requires, I should have a whole separate
file just to isolate the requires? Is there some other purpose, because
that just makes no sense.

Looking for insight. Thx.

– gw

Greg,

I spent a lot of time today building a Rails 3 plugin, and
The Basics of Creating Rails Plugins — Ruby on Rails Guides is outdated. I will be
looking into updating the page for Rails 3.

Below is the recommended setup, where init.rb requires only lib/
plugin.rb. I’m not 100% positive, but I believe it is done this way
to conform to the Rails Engine.

/PLUGIN/init.rb
/PLUGIN/lib/plugin.rb


Andrew Ferk

Andrew Ferk wrote:

I spent a lot of time today building a Rails 3 plugin, and
The Basics of Creating Rails Plugins — Ruby on Rails Guides is outdated. I will be
looking into updating the page for Rails 3.

Below is the recommended setup, where init.rb requires only lib/
plugin.rb. I’m not 100% positive, but I believe it is done this way
to conform to the Rails Engine.

/PLUGIN/init.rb
/PLUGIN/lib/plugin.rb

Thanks. Could init.rb include anything other than the require? Perhaps
the definition of some constants? Or would you do everything in
/lib/plugin.rb?

Also, how would you deal with a case where the name of the plugin might
be SpiffyUser, and you have /plugins/spiffy_user/lib/spiffy_user.rb
where I would want a class file named spiffy_user.rb – seems now like
we want to use spiffy_user.rb for two things. Plugin init and a primary
class file for the plugin.

I guess I just have to come up with another name for one of them, but
it’s not really ideal to have to do that I think. Or, let’s just say
under the old system I didn’t have to when we could have the actual init
stuff in init.rb

Sure seems like there should be /PLUGIN/lib/init.rb

– gw

Dear Andrew or anybody else who can help,

I have been executing the The Basics of Creating Rails Plugins — Ruby on Rails Guides
verbatim and everything works as expected up to section 5. On
implementing section 6, I get the following error which I cannot
eliminate. Any help would be appreciated.

Summary of error:

  • require ‘action_controller/test_process’ appears to be causing the
    problem but I can’t figure out a solution / work-a-round to overcome

Environment: Windows 7 with Ruby 1.8.7 p249, Rails 3.0.1

BTW, http://localhost:3000/woodpeckers/index WORKS

Application: name=t1

  • plugin_name=djcc
  • directory=RAILS_ROOT/vendor/plugins/djcc
  • command=rake

Regards

Balbir
Andrew Ferk wrote in post #942025:

Greg,

I spent a lot of time today building a Rails 3 plugin, and
The Basics of Creating Rails Plugins — Ruby on Rails Guides is outdated. I will be
looking into updating the page for Rails 3.

Below is the recommended setup, where init.rb requires only lib/
plugin.rb. I’m not 100% positive, but I believe it is done this way
to conform to the Rails Engine.

/PLUGIN/init.rb
/PLUGIN/lib/plugin.rb


Andrew Ferk