Environment: heroku
Rails: 4
Ruby: 2
We deployed an app to heroku, and it seemed as though anything in the public folder was not accessible (didn\'t see
In previous Rails versions, Heroku injected a plugin that enabled serving of static assets so this issue didn't exist. As this plugin system was removed in Rails 4, they now created a gem which does the same. You enable it in your Gemfile via:
gem 'rails_12factor', group: :production
See Getting Started with Rails 4.x on Heroku
You could also of course use a CDN for your assets, but you're not required to.
For Rails 5+ work on twelve-factor platforms out of the box and the gem is no longer required
The rails guides are wrong. Try...
config.assets.serve_static_files = true
This is deprecated in Rails 4.2, and it is now an alias slated to be removed in Rails 5.0
config.serve_static_assets = true
It should be changed to:
config.serve_static_files = true
As Dean Winchester mentioned it, it is a good idea to use a CDN for your static assets. In fact when using only Heroku your Rails application would have to be responsible to serve static assets since Heroku Cedar architecture will not do that for you.
Setting config.serve_static_assets = true
is the way to go if you don't want to configure a CDN and use only Heroku.