Reputation: 11476
I have a rails app configured on my Raspberry Pi 2. It's on my local LAN getting the same ip over and over from the router. It has mDNS configured so I can access it at mypi.local.
Configured apache2 and passenger for that local domain. Now when I enter mypi.local in my browser I see the app. Great!
It works, but for some unknown reason I get all the app's html but without any CSS and Javascript. I can interact with parts of the site which are not Javascript dependent and my browser's default CSS kicks in.
Any ideas?
If I launch WEBrick and try mypi.local:3000 everything works as expected.
Upvotes: 0
Views: 382
Reputation: 5112
this is because things work differently in development as compared to production. few thing to note:-
config.precompile
directive.Only application.css
and application.js
are available by default of all the CSS and JS files.public/assets
folder when you compile your assets.So if you want to add some web fonts, you could make an app/assets/fonts/ folder and put your fonts in there, these will then be copied to public/assets/fonts
folder when you compile your assets. Note that your app/assets/stylesheets/fonts.css.scss
file that references those fonts will NOT be copied over unless you either added it to the config.assets.precompile
directive or required it from your application.css
config.assets.compile
...If it is set to "true" (which it is by default in development) then Rails will try to find a Javascript or CSS file by first looking in the public/assets
directory and if it can't find it, will hunt through your app/assets
folder looking for the file. If it finds it in app/assets
it will go ahead and compile on the fly and then serve this asset up.The problem with this is that you don't notice it happening in development, then you commit everything and push to production and BOOM, everything is broken with 500 errors because production has config.assets.compile
set to "false".This prevents the app from "falling back" and trying to load the file directly instead of using the asset pipeline.
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
Why don't you just have this set to "true" in every environment? Well, because it is sloooooow. And you don't want slow in production
RAILS_ENV=production rake assets:clean assets:precompile
Upvotes: 1