Skip to content
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

In development - handling assets that don't exist #19

Closed
conrad-vanl opened this issue Oct 9, 2013 · 7 comments
Closed

In development - handling assets that don't exist #19

conrad-vanl opened this issue Oct 9, 2013 · 7 comments

Comments

@conrad-vanl
Copy link

I noticed that an exception is triggered if I try to go to an asset url that doesn't exist instead of a 404 (or handling it gracefully).

Would it be beneficial to include something like pass if !asset somewhere around here: https://github.com/kalasjocke/sinatra-asset-pipeline/blob/master/lib/sinatra/asset_pipeline.rb#L50

@kalasjocke
Copy link
Owner

Sounds like a great idea. Do you have the chance to try it out and create a pull request?

@kalasjocke
Copy link
Owner

However, after giving it some more thought it only raises an exception in the development environment as all assets are served via the default Sinatra public folder in production. Do you still think we need the if statement?

@conrad-vanl
Copy link
Author

It's a very minor detail that I only noticed because I was migrating an app from rake-pipeline to this and some of our previous urls were displaying this error instead of 404'ing (or something else to tell me that the asset didn't exist). It took me a while to figure out that I had a path mis-configured.

With using sprockets-helpers you shouldn't ever be able to generate a URL to an asset that doesn't exist, so in theory it wouldn't matter too much. Only use case I could come up with is if an implementer needed their sinatra app to handle certain urls that began with "/assets" ... maybe like if they wanted to use sinatra to dynamically serve a user profile photo - "/assets/user/:id" or something. If it means anything, I think Sprocket's built-in rack middleware passes if it comes across an asset that doesn't exist, but I could be wrong.

If you think it's relevant enough to issue a PR I'll do so and test it out.

@kalasjocke
Copy link
Owner

Got it, I would love a pull request!

@kalasjocke
Copy link
Owner

Closing this issue, please reopen it if you find the time to make a pull request.

@plukevdh
Copy link
Contributor

I think this could still be useful, even if it were just a more explicit error message, saying which asset it was trying to find.

@kalasjocke
Copy link
Owner

I agree, a friend of mine using this library just ran into the same problem the other day, so I think that we should reopen this, do some work and get this feature in.

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

No branches or pull requests

3 participants