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
Rails 3.1.1 - Asset Pipeline - asset.prefix not working with resource :assets #3643
Comments
+1 I cant get this working either |
I also get this issue on an existing application which uses an Asset resource. |
relf the issue seems to be that each person that comes across this issue fixes it from there point of view. The underlying issue is that asset_path is wrong when you add your own route for assets. I have forked rails to show what i am going to use for the time being. https://github.com/nodrog/rails/tree/asset_path_conflict I dont think that the sprockets helper should have a asset_path in it, so i have changed it to pipeline_path and defaulted the value of the config.asset.prefix to 'assets'. The only disadvantage to this is that you can no longer use 'asset_path' to link to your assets. But in the main it dose not seem that this should be done, the other helpers are better 'image_path', 'javascript_include_tag' etc. I am not sure how else to fix it, as depending on if you use the prefix or not then asset_path will come from your routes and cause an issue or come from the sprockets helper and cause problems. thoughts from people much cleverer than me would be much appreciated... for the time being i will use my fork |
Seems to be same issue I'm experiencing. Fork above solve the problem, but could someone actually validate the fix is that the correct way it should be done. |
Also having troubles with this issue. |
Your fork helped me figure out what's wrong here. Its a tough one! My gut suggests that there should be an option to namespace the asset pipeline, or simply give the asset_path method a prefix, or to simply define it by a configuration setting. FYI - another alternative is to use :as => 'notassets' or something in routes.rb so that the helper methods don't collide. Of course the helper methods to your objects will not be asset_path, but imho that's easier to manage. |
thanks docunext, yes it seems right now there are not quite enough options to make it work as intended. I had not thought of using the :as option, very good idea, will work for now, but people are going to keep hitting this issue, as Asset i would think is a particularly common name to use in an app! pipeline might have been better, although a friend has worked on a oil pipeline leak application so a totally safe name would not be practical. |
This still being a issue in 3.1.3? |
i have not had a chance to try it |
Tested its still not work in 3.1.3 same issues. |
I just tested using rails from 3-1-stable branch, this is fixed with a2f4ef1 and will work fine in Rails 3.1.4 and 3.2.0 |
thanks guilleiguran you are a star... |
I am having an issue with the asset pipeline, I already have a resource / controller called assets. So i have changed assets.prefix option to "/externals".
This simple dose not work unless i remove:
Then all works as expected.
I am not sure how to write a test to prove this but i have created a app to showcase it.
https://github.com/nodrog/asset-pipeline-issue
If you run the app, and visit '/products' all will work, then go to the routes file and change the variable create_bug to true.
We have looked into https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/helpers/rails_helper.rb, and then added a debugger to the asset_path method.
This method is not called, if you but a debugger in the javascript_include_tag method. And run method(:asset_path).source_location, it tells you it is calling the method from default routes not from the sprockets helper.
Any help would be greatly appreciated...
The text was updated successfully, but these errors were encountered: