Using Rails 3.1, where do you put your “page specific” JavaScript code?

前端 未结 29 2304
一生所求
一生所求 2020-11-22 11:08

To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your appl

29条回答
  •  忘掉有多难
    2020-11-22 11:37

    I haven't tried this out, but it looks like the following is true:

    • if you have a content_for that is javascript (e.g. with real javascript within it), sprockets would not know about it and thus this would work the same way as it does now.

    • if you want to exclude a file from the big bundle of javascript, you would go into config/sprockets.yml file and modify the source_files accordingly. Then, you would just include any of the files that you excluded where needed.

提交回复
热议问题