Developing plugins

Hi *, I'm trying to develop a plugin, but I'm having some problems integrating it in Rails.

The first problem is when I need to load the environment: I would like the plugin to be installable in the classic way (under /vendor) and as a gem. Right now I'm using something like

require File.join( File.dirname( __FILE__ ), '..', '..', '..', '..', 'config', 'environment' )

but of course I don't think it will work as a gem. How can I require the env to have it work in both ways ?

The other problem I'm facing is when I try to have the plugin to include itself inside ActionController (an example can be login_required of restful authentication). This is what I'm trying to do:

$:.unshift File.expand_path( File.dirname( __FILE__ ) ) require 'charon/class_methods'

module Charon   #some stuff end

ActionController::Base.send :include, Charon::CharonClassMethods

and in charon/class_methods

module Charon      module CharonClassMethods

    def self.included base       base.send :extend, Charon::CharonClassMethods::ClassMethods     end

    module ClassMethods

      def authentication_url         # implementation       end

    end

  end

end

What I don't understand where I should include the main application, how to load rails and when (I can require ActionController in the first file but it doesn't feel right ...) and what to put inside hte various initialization files. If someone knows of a plugin with specs that I can copy I would be very glad. It's not that I don't find them, but every plugin I find does things in a different way, so it's not entirely clear which way is the best one.

TIA,   ngw

What I don't understand where I should include the main application, how to load rails and when (I can require ActionController in the first file but it doesn't feel right ...) and what to put inside hte various initialization files. If someone knows of a plugin with specs that I can copy I would be very glad. It's not that I don't find them, but every plugin I find does things in a different way, so it's not entirely clear which way is the best one.

Well the rails framework (and constituent parts) will already have been loaded at the point your init.rb is run. requiring config/ environment again at that point probably doesn't do anything at all. For a gem plugin if my memory is correct you'll want to ensure rails/ init.rb exists (and do your rails specific setup in there).

Fred