diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/log_subscriber.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actionview/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb index 354a136894..9336b29d0b 100644 --- a/actionview/lib/action_view/log_subscriber.rb +++ b/actionview/lib/action_view/log_subscriber.rb @@ -5,7 +5,12 @@ module ActionView # # Provides functionality so that Rails can output logs from Action View. class LogSubscriber < ActiveSupport::LogSubscriber - VIEWS_PATTERN = /^app\/views\//.freeze + VIEWS_PATTERN = /^app\/views\// + + def initialize + @root = nil + super + end def render_template(event) return unless logger.info? @@ -23,8 +28,13 @@ module ActionView protected + EMPTY = '' def from_rails_root(string) - string.sub("#{Rails.root}/", "").sub(VIEWS_PATTERN, "") + string.sub(rails_root, EMPTY).sub(VIEWS_PATTERN, EMPTY) + end + + def rails_root + @root ||= "#{Rails.root}/" end end end |