rails 4 enabled rails to serve static assets: is it correct? (on heroku)

前端 未结 4 1614
长情又很酷
长情又很酷 2021-02-01 03:15

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

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 04:03

    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

提交回复
热议问题