문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top