Reputation: 2363
All of the stylesheet subfolders on my Rails 4 app are working in Heroku except one. The one that doesn't work works FINE in development, but when I deploy it, it doesn't work. It shows a 404 error and loads everything except the scss. I have 2 different namespaces in addition to the root, "blog" and "admin". It's the "admin" subfolder that doesn't work, but it's structured the same as the "blog" subfolder and the "theme1" subfolder of the main site...which both serve the assets fine.
I've tried all the usual asset debugging for asset pipeline (serve_static_files, clean assets, precompile) and it doesn't make a difference because MOST of my assets are working, just not this one folder.
Here is my file structure: stylesheets
├── admin_manifest.scss # this is precompiled
├── _admin
| ├── css
├── "10 stylesheets"
| └── admin.scss #@imports of the 10 stylsheets & fonts
├── application.scss # this is precompiled and includes the theme1_manifest.scss as well as plugins, jquery, etc
├── blog_manifest.scss # this is precompiled
├── _blog
| ├── shortcodes.scss
| └── theme_style.scss
├── theme1_manifest.scss # this is precompiled
├── _theme1
| ├── shortcodes.scss
| └── theme_style.scss
Again, the blog and theme1 subfolders work perfectly, and the admin subfolder works in development, I just can't figure out why it doesn't work in production.
Upvotes: 2
Views: 1083
Reputation: 899
The problem arises in a production environment and works perfectly fine in development environment indicates that the assets are not being complied.
This is an issue related to the configuration of a Rails app in Heroku.
One solution is to precompile the assets in development environment and upload the compiled assets to heroku.
To know more about this, read about Heroku configuration for a rails app.
Follow the following steps:
Ensure the following in the file /config/environments/production.rb
:
config.cache_classes = true
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
Add the gem rails_12factor
along with pg
gem in production
gem 'rails_12factor'
Precompile the css files:
bundle exec rake assets:precompile RAILS_ENV=production
Commit and push the css files to heroku:
git add .
git commit -m "Precompiled assets"
git push heroku master
Upvotes: 3