0

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, that would explain why it didn't execute then. Thanks for the information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.