Running code before allowing user requests?

I’ve been poking around using my search-fu to look for a way to run
code after Rails 3 has initialised but before any requests are
services. I was thinking of scenarios like migrating the database or
forcing administrators to set values to new application configuration
properties and things like that.

I think using Railties would work but I was wondering if there was
already something out there (Railtie, plugin) before I tried to re-
create the wheel so to speak. Anyone know of anything or implemented
something similar?

On Mar 20, 4:30pm, cdempsey [email protected] wrote:

I’ve been poking around using my search-fu to look for a way to run
code after Rails 3 has initialised but before any requests are
services. I was thinking of scenarios like migrating the database or
forcing administrators to set values to new application configuration
properties and things like that.

How about in boot.rb or is that too early ?

I wouldn’t recommend using that kind of process for migrations though,
you could have bad side effects, for instances if two instances of
rails get started up (by accident, crash recovery mechanism, etc.) and
both attempt to perform the migration.

Katie

http://www.coderstack.co.uk/ruby-developer-jobs

It sounds like you want an admin mode to do some setup before the app
goes live. If that’s the case, why not have a special controller for
that purpose and some logic to redirect to that controller if the app
is in a nascent state? Seems like one of the wizard recipes could also
apply nicely here.

Martin