Rails and plugin irritation.


I’ve just started work on a medium sized Rails-application (100-200 hours), and about the first thing I wanted to do was to add my CAS filter (see next posting) to the system. Now, what I’d really like is to be able to set the filter to fake authentication while doing development on my box but going to real authentication when in production. I first tried using $RAILS_ROOT/config/environments/development.rb to set this option, but this doesn’t work. Plugins are loaded really late in the startup sequence so my best choice is to add

load “plugin/#{ENV[‘RAILS_ENV’].rb” if File.exist?(“plugin/#{ENV[‘RAILS_ENV’].rb”)

at the end of environment.rb and add my specific configuration to $RAiLS_ROOT/plugin/development.rb

This works, of course, but it is something that I’d thought would already be part of the startup process. Oh well, you can’t have everything.


One Comment, Comment or Ping

  1. Charles Oliver Nutter

    The late-loading-plugin thing is a real pain for us too, since we can’t add the ActiveRecord/JDBC adapter to an existing Rails app using the plugin mechanism. ActiveRecord is initialized way before the plugins are, so we have to hack around it. I believe Nick Sieger came up with one reasonable hack, whereby we disable ActiveRecord until the plugin loads, and then re-enable it. It’s not great however, and the inability to provide core features through plugins seems a pretty serious lacking.

    July 15th, 2006

Reply to “Rails and plugin irritation.”