Ruby on rails before_filter function not executing

582 views Asked by At

So there's a bit of code that I want to execute on every request that is made to my rails application and found through googling that I can do it using before_filter. Buy it doesn't seem to run when I go to the initial page, which is localhost:3000. Anyone know why it doesn't run?

I'm using Ruby on Rails 3, WebBrick server on Lubuntu Linux.

class ApplicationController < ActionController::Base
  before_filter :run

  private
  def run
    logger.debug "run? I'm too tired"
  end
end
1

There are 1 answers

1
Kevin Sylvestre On BEST ANSWER

If your initial page is a 'static' page served from the public directory this code will not be run. To fix, make the page render as the result of some controller's action that inherits from ApplicationController.