-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise MissingAssetError in compute_asset_path instead of each resolver
Follow-up to 0fd7814: Rather than adding this `raise` to each resolver's `resolve` method, let's move it into Propshaft's `compute_asset_path` implementation. `compute_asset_path` is the ActionView method that asset pipeline gems are expected to implement [1] [2], which makes it 1) the highest level for us to catch missing assets and 2) the entry point for anyone looking to understand how Propshaft integrates with the ActionView helpers (thus, it's helpful to have that method's definition explicitly include the exception it raises, just like sprockets-rails does [3]). [1]: https://github.com/rails/rails/blob/099289b6360ac82d1e0fa0a5592ac10cfc05e6e0/actionview/lib/action_view/helpers/asset_url_helper.rb#L132-L133 [2]: https://github.com/rails/rails/blob/099289b6360ac82d1e0fa0a5592ac10cfc05e6e0/actionview/lib/action_view/helpers/asset_url_helper.rb#L262-L265 [3]: https://github.com/rails/sprockets-rails/blob/118ce60b1ffeb7a85640661b014cd2ee3c4e3e56/lib/sprockets/rails/helper.rb#L84
- Loading branch information
Showing
5 changed files
with
5 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Propshaft::Helper | ||
def compute_asset_path(path, options = {}) | ||
Rails.application.assets.resolver.resolve(path) | ||
Rails.application.assets.resolver.resolve(path) || raise(Propshaft::MissingAssetError.new(path)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters