Skip to content

Explicit API to error when an asset is not found #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2016

Conversation

schneems
Copy link
Member

@schneems schneems commented Sep 7, 2016

The goal here is that we can eventually extend this to look for common problems. For example in the future if you try to load asset_path(assets/javascripts/application.js) you might get an error telling you that you that you should leave off the paths in front of the asset. We could also look for assets with the same name and different file extensions as well as do a did you mean type levenshtein lookup for possible asset mis-spellings.

We can't do any of that today because there is no guarantee that you expect find_asset to return a valid result. By introducing an explicit api find_asset! we can guarantee the user either wants an asset or an error.

The goal here is that we can eventually extend this to look for common problems. For example in the future if you try to load `asset_path(assets/javascripts/application.js)` you might get an error telling you that you that you should leave off the paths in front of the asset. We could also look for assets with the same name and different file extensions as well as do a `did you mean` type levenshtein lookup for possible asset mis-spellings.

We can't do any of that today because there is no guarantee that you expect `find_asset` to return a valid result. By introducing an explicit api `find_asset!` we can guarantee the user either wants an asset or an error.
@schneems schneems merged commit d590c1c into master Sep 9, 2016
@jeremy jeremy deleted the schneems/error-when-asset-not-found branch November 3, 2016 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant