Include Assets Only If They Exist

前端 未结 5 1698
情歌与酒
情歌与酒 2021-02-19 07:41

In our current rails app, we are following certain patterns for including assets such as scripts and stylesheets.

For instance, one such pattern is (code inside the layo

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 07:59

    = stylesheet_link_tag controller.controller_name if File.exists?(File.join(Rails.public_path, 'assets', "#{controller.controller_name}.css"))
    

提交回复
热议问题