Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails.configuration.to_prepare code not getting executed

#5433

I'm using the rails_warden gem, which via middleware magic injects a lazy proxy object as env['warden']. When I wrap its initialization in config.to_prepare env['warden'] is nil.

my config/initializers/warden.rb:

Rails.configuration.to_prepare do
 Rails.configuration.middleware.use RailsWarden::Manager do |config|
  config.failure_app = UserSessionsController
  config.default_strategies(:awesome)
 end
 Warden::Strategies.add(:awesome) do
  def authenticate!
   user = User.find(1)
   success!(user)
  end
 end
end

after booting the app, I tried to do some logging statements and raise a runtime error:

Rails.configuration.to_prepare do
  logger.info "this did not show up in my logs"
  raise "and this did not get raised"
  Rails.configuration.middleware.use RailsWarden::Manager do |config|
  ...
end

but neither worked, a whiny nil was raised when the request called env['warden'].authenticate!

all of this works without the to_prepare block, but it's a bit of a pain to restart the app everytime there is a change.

Reported by dennis collective · August 24th, 2010 @ 09:22 AM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • Importance changed from to Low

    If I add following lines to my code then I do get raise message. Can you elaborate on what is the issue you are running into.

    Rails.configuration.to_prepare do
      puts "this did not show up in my logs"
      raise "and this did not get raised"
    end
    

    December 9th, 2010 @ 02:35 AM

  2. rails
    rails
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    March 10th, 2011 @ 12:00 AM

  3. rails
    rails
    • State changed from open to stale

    March 10th, 2011 @ 12:00 AM