@@ -77,7 +77,7 @@ def compute_asset_path(path, options = {})
77
77
File . join ( assets_prefix || "/" , legacy_debug_path ( asset_path , debug ) )
78
78
else
79
79
result = super
80
- if respond_to? ( :public_asset_path )
80
+ if respond_to? ( :public_compute_asset_path )
81
81
throw ( :asset_not_found , result )
82
82
else
83
83
result
@@ -93,7 +93,7 @@ def asset_path(*args)
93
93
end
94
94
95
95
result = catch_asset_not_found
96
- deprecate_invalid_asset_lookup ( result , caller )
96
+ deprecate_invalid_asset_lookup ( result , respond_to? ( :caller_locations ) ? caller_locations : caller )
97
97
result
98
98
end
99
99
alias_method :path_to_asset , :asset_path # aliased to avoid conflicts with an asset_path named route
@@ -266,43 +266,14 @@ def legacy_debug_path(path, debug)
266
266
end
267
267
268
268
private
269
- # Attempts to extract a method name from a given caller line
270
- #
271
- # Example:
272
- #
273
- # extractd_method_from_call_frame('console.rb:65:in `start'') => 'start'
274
- def extract_method_from_call_frame ( frame )
275
- frame . split ( "in " . freeze ) . last . gsub ( /`|'/ , '' . freeze )
276
- end
277
-
278
269
# Emits a deprecation warning when asset pipeline
279
270
# is used with an asset that is not part of the pipeline.
280
271
#
281
272
# Attempts to determine proper method name based on caller.
282
273
def deprecate_invalid_asset_lookup ( name , call_stack )
283
274
message = "The asset #{ name . inspect } you are looking for is not present in the asset pipeline.\n "
284
275
message << "The public fallback behavior is being deprecated and will be removed.\n "
285
-
286
- append = nil
287
-
288
- # We need to figure out the actually deprecated method. This is complicated since
289
- # the deprecation always comes from `asset_path` but that might not be the API that
290
- # is being used. To solve this we look at the call stack methods backwards and figure out the first
291
- # `*_url`, `*_tag` or `*_path` method that is called. If that method also has a `public_*`
292
- # counterpart it is the first method that was called that could be deprecated.
293
- call_stack . reverse_each . detect . with_index do |call_frame , index |
294
- method_name = extract_method_from_call_frame ( call_frame )
295
- next if !method_name . end_with? ( "_url" . freeze ) &&
296
- !method_name . end_with? ( "_tag" . freeze ) &&
297
- !method_name . end_with? ( "_path" . freeze )
298
-
299
- if self . respond_to? ( "public_#{ method_name } " )
300
- append = "please use the `public_*` helper instead. For example `#{ "public_#{ method_name } " } `.\n "
301
- call_stack . shift ( call_stack . length - index - 1 )
302
- end
303
- end
304
- append ||= "please use the `public_*` helper instead for example `public_asset_path`.\n "
305
- message << append
276
+ message << "pass in `public_folder: true` instead.\n "
306
277
307
278
ActiveSupport ::Deprecation . warn ( message , call_stack )
308
279
end
0 commit comments