Skip to content

Commit 7833a35

Browse files
authored
Merge pull request #26 from kevintyll/master
Eliminate Rails 5 deprecation warning.
2 parents f7e7049 + 89c28cf commit 7833a35

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'premailer'
22

3-
Premailer.class_eval do
3+
module LoadFileWithRailsPath
44
protected
55
# When using the 'stylesheet_link_tag' helper in Rails, css URIs are given with
66
# a leading slash and a cache buster (e.g. ?12412422).
77
# This override handles these cases, while falling back to the default implementation.
8-
def load_css_from_local_file_with_rails_path!(path)
8+
def load_css_from_local_file!(path)
99
# Remove query string and the path
1010
clean_path = path.sub(/\?.*$/, '').sub(%r(^https?://[^/]*/), '')
1111
rails_path = Rails.root.join('public', clean_path)
@@ -14,10 +14,12 @@ def load_css_from_local_file_with_rails_path!(path)
1414
elsif (asset = Rails.application.assets.find_asset(clean_path.sub("#{Rails.configuration.assets.prefix}/", '')))
1515
load_css_from_string(asset.source)
1616
else
17-
load_css_from_local_file_without_rails_path!(path)
17+
super(path)
1818
end
1919
end
20-
alias_method_chain :load_css_from_local_file!, :rails_path
20+
end
2121

22+
class Premailer
23+
prepend LoadFileWithRailsPath
2224
end
2325

0 commit comments

Comments
 (0)