Skip to content

Comment on Continuous Cache Warming for Railsparent

Comments

I needed this in a rake task under Rails 2 a while back; I ended up doing the following:

  require 'action_controller/integration'
  app = ActionController::Integration::Session.new

  module CurrentUserHack
    def current_user 
      @user ||= User.look_up_my_user_here
    end
  end
  ApplicationController.send :include, CurrentUserHack
Now you can make authenticated requests in rake tasks and presumably in script/runner.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.