-
Notifications
You must be signed in to change notification settings - Fork 85
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
Roadie::CSSFileNotFound with Rails 3.2/roadie 2.3.0.pre1 #18
Comments
Dive into your console, to the "staging" env and check this:
Roadie.app is exactly the same as Rails.application, but you can check both just to be on the safe side. If Roadie.app.assets.path doesn't list '/public/assets' in which are the compiled assets then you have your answer.
|
I would like to know if that is the case, and if it is, what paths are present instead? |
Here's the output of
No '/public/assets' to be found. Just out of curiosity, here's the output of
|
I just completely deleted the Roadie gem (including the cache) and reinstalled to rule that out: no change. Here is a full backtrace of the exception:
|
That's so strange. I mean, What happens when you try the following in the console?
|
The output of
But the file I'm pretty new to Rails so hopefully this makes sense. Thanks so much for your help! |
In you asset.pats you don't have the public assets dir. Go to config/application.rb and add the line Rails.application.assets.path << Rails.root.join 'public', 'assets' |
I understand that's what you did as a workaround, but that doesn't seem to actually fix the root cause. Nothing has changed in my app other than an upgrade to Rails 3.2 and Roadie 2.3.0.pre1. Adding the public dir to the assets path doesn't explain why it worked before and why it works now for everything other than Roadie. |
FYI: Whenever I try to add to add the public/assets directory the assets.paths I get the following exception:
I get this both locally and in staging. |
If you're getting such exception that means that you eventually didn't add 'public/assets' to assets.path. If you would have added the path your problem would be resolved. |
Maybe I'm misunderstanding something, but whenever I attempt to add another path to the And even if it worked, it still wouldn't be the correct answer IMO. My configuration worked before I upgraded to Rails 3.2 and Roadie 2.3.0.pre1 - and those were the only things I changed. |
Yeah, seems to be a real problem from my side. I'll check out to see if I'm interfacing Sprockets correctly. |
Ah, I think I get it now! The rendered HTML has a tag like this: <link rel="stylesheet" href="/assets/email-sha.js" type="text/css" /> This causes Roadie to look for an asset named I'm not sure which way would be best to fix this, actually. Here are two ideas:
Anyone of you want to help me decide on the approach? In the mean time, @wgrrrr, here are some workarounds to get your app up and running again; pick one:
|
Exactly @Mange, the rendered asset tag is as you specified (except it's CSS not JS - I think you meant CSS). I believe that when the Asset Pipeline is enabled Roadie should definitely look for compiled assets in the public/assets directory. This allows people to use Sass, Less, etc. inside of their email.css. If you just look for uncompiled assets they aren't going work (if using Sass/Less/etc.), or dev's will not be able to use those facilities. Thanks for your suggestions! Take care. |
Indeed.
The Asset Pipeline compiles them for us if they aren't compiled. Problems occur when the current environment is using precompiled assets instead of compiling on the fly. I'm going to try to make the provider a bit smarter and see if I can make it work with them as well. |
Hmmm... the default in production environments for >Rails 3.1 is to precompile assets. Are you saying that people need to disable precompiling and enable compile on-the-fly? I had Roadie working with precompiled assets before my 3.2 upgrade... seemed to work fine. |
No, that's just a temporary work-around until I get this fixed. Roadie need to look for precompiled assets on the filesystem while still fetching non-compiled assets from the asset pipeline. It's a bit strange that it worked before. There was no code in place to handle precompiled assets. Perhaps your view changed? |
Workaround is now mentioned in the README as a "Note:". |
Just for anyone trying to get Roadie working with precompiled assets (based on what @Mange said): # config/environments/production.rb:
Monday::Application.configure do
config.roadie.provider = Roadie::FilesystemProvider.new(Rails.root, "public")
end # app/views/layouts/mailer.html:
<link rel='stylesheet' type='text/css' href='/assets/email.css'> |
@moll this is a fix, but the config should be: config.roadie.provider = Roadie::FilesystemProvider.new("", Rails.root.join("public")) and the <link rel='stylesheet' type='text/css' href='assets/email.css'> |
@schiza From looking at the code, IIRC, the two ways to init FilesystemProvider are equivalent. Why do you recommend one over the other? Btw, I find the prefixed |
Maybe I was too hasty, but I had some problems with both of these things, even if they looked right, after looking at the code. Maybe my misspelling, but maybe it will help someone.. |
Let me explain the The prefix is automatically removed from the URLs it encounters when it tries to match to disk. The purpose is to be able to say that all stylesheets live in The normal way you should use this is by initializing it like this: config.roadie.provider = Roadie::FilesystemProvider.new('/assets', Rails.root.join('public', 'assets')) But once again, I cannot stress this enough: It's much, much, much more simpler if you just tell Roadie which stylesheet to use from the Mailer. Relying on Roadie correctly guessing where your stylesheet is will never be bulletproof. This is how I do it, and I really recommend it. class Notifier < ActionMailer::Base
defaults css: 'email'
end I am working (albeit slowly) on a fix for this. It's going to be the next minor version since it will break backwards compatibility with this version when it comes to configure the providers. It will also add a new provider that just tries multiple providers in order until an asset is found. |
This error just suddenly appeared on me. Am I understanding correctly that Roadie needs a special provider that looks in assets and public/assets? |
@ZhangBanger For a [quick] fix, check out my instructions above. |
@moll Apologies, found the error: I was using BOTH stylesheet_link_tag AND default css: 'user_mailer' Apparently, stylesheet_link_tag was working fine in development, but caused production breakage. |
Either do |
Problems like these should be fixed in |
Fix compare links in Changelog.md
This is similar to #15. I'm also seeing a Roadie:CSSFileNotFound exception with Rails 3.2 and Roadie 2.3.0.pre1. It was working for me with Rails 3.1 and Roadie 2.2.0. I tried the fix mentioned by maraczek in #15, but that didn't work for me.
The specific exception I'm getting is:
I have verified the file exists and is in the correct location. This is my staging environment, which is configured exactly like a production environment. I'm deploying using Capistrano.
Any thoughts?
The text was updated successfully, but these errors were encountered: