How do you limit CoffeeScript (or JavaScript) execution to a particular controller and action in Rails 3.1?

前端 未结 5 681
攒了一身酷
攒了一身酷 2021-01-02 09:50

The new Rails 3.1 asset pipeline is really nice, but since all CoffeeScript (or JavaScript) files get melded down into a single file that is included in every page, it raise

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 10:40

    what i normally do is to have a yield :js under the javascripts in my layout and when I need a specific script it, I load it directly from my view with:

    content_for :js do
        javascript_include_tag "myscript"
    end
    

提交回复
热议问题