Skip to content

Commit 2bc416b

Browse files
Undefine Rails' assets method before redefining it, to avoid warnings
Rails test suite keeps raising: warning: method redefined; discarding old assets warning: method redefined; discarding old assets= Because sprockets-rails is monkey-patching Rails::Application, redefining the assets method, and adding an attr_writer for it. This undefines the existing method before adding the new one, avoiding the warning. The writer call is also removed, since Rails defines an attr_accessor that already adds it.
1 parent c56eddb commit 2bc416b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/sprockets/railtie.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Configuration
1414
end
1515
end
1616

17+
# Undefine Rails' assets method before redefining it, to avoid warnings.
18+
undef_method :assets
1719
# Returns Sprockets::Environment for app config.
1820
def assets
1921
return @assets if defined? @assets
@@ -29,7 +31,6 @@ def assets
2931
end
3032
end
3133
end
32-
attr_writer :assets
3334
end
3435
end
3536

0 commit comments

Comments
 (0)