-
Notifications
You must be signed in to change notification settings - Fork 244
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
loading assets via mountable engine in rails 4 #32
Comments
Sorry but I didn't understand what is you doubt. assets are not served in the engine prefix since who will serves it is your webserver and it doesn't know anything about how you mounted the engine. So the engine assets are served in the same URL of the application assets. |
Ok, so that's hard to come back from.. I guess I'll do my best to write a failing test -- or would you rather have a project you can clone to see the issue in? |
@jejacks0n if you could create a project to close would be great. Thank you |
no worries. =) so, I understand the confusion a little more now. The case we're talking about is when it's a view from within the engine. You're correct, if I have a view in your application It's only when attempting to load an asset from within a view in the engine that this happens (like a layout, or controller with it's own views). I can say that it has to do with where the engine is mounted -- and I'll do more investigation into this when I create an example project. |
@rafaelfranca - Here's an example of using javascript_include_tag from within an engine layout, and how the path at which the engine was mounted is being prepended to the /assets path. Thanks for taking a look at it. The example app is pointing to master on all it's dependencies -- so it should be current.. it's loading an engine from lib, and the routes for the engine are defined in config/routes.rb -- maybe a little convoluted, but it's the simplest way to accomplish it. |
I added a commit to Teabag that tries to address this issue (and the duplication one) -- and I'd appreciate feedback/thoughts. I don't like having the shim, but I don't see an obvious alternative. The project is Teabag, and the commit is 467adc0 The way the test runner works is by using a file matcher to glob spec files. It loads them using The issue of prepending the engines path (where it was mounted), generates more complication here, and the fact that the api has changed between rails 3.2 and rails 4 adds to it. Again, this is mostly about getting things dialed for users, so thoughts would be welcomed.. I avoided manifest files because I want to provide a way to run single spec files from the command line. |
Tracked the issue back to action_view/helpers/asset_url_helper.. I left a comment on the commit that causes the path to be prepended. |
Meh, I'm just hammering away on this one waiting for clarification -- in the meanwhile I submitted a pull request that fixes this in rails. |
👍 |
A patch for this was merged in Rails some time ago |
routes.rb
When you attempt to load an asset from within this engine, the mounted path is prefixed before assets.. so
/teabag/assets/teabag-jasmine.js
, but this file isn't served at that path -- it's still at/assets/teabag-jasmine.js
What are the plans with this? I totally understand having the assets from an engine served from a different path (and agree), so is there something I'm missing in getting that to work?
The text was updated successfully, but these errors were encountered: