开发者

Rails 3: Where to put js/css plugins without separating files?

开发者 https://www.devze.com 2023-02-16 08:26 出处:网络
Rails beginner here. I want to use a few plugins (such as videoJS or jQuery UI) that contain both CSS and Javascript files in their downloads. I see that rails separates the two, putting JS in public/

Rails beginner here. I want to use a few plugins (such as videoJS or jQuery UI) that contain both CSS and Javascript files in their downloads. I see that rails separates the two, putting JS in public/javascript and CSS in public/stylesheets.

Where should I put the files s开发者_Python百科o that I can keep the JS and CSS together, and how do I reference them?


You can put JS and CSS anywhere you want in public dir. For example: you have got videoJS plugin in public dir:

public
  - stylesheets
  - javascripts
  - videoJS
    - videojs.js
    - videojs.css
    - reset.css
    - jquery.min.js

So now you just need to add this:

<%= stylesheet_link_tag '/videoJS/videojs', '/videoJS/reset' %>
<%= javascript_include_tag '/videoJS/videojs', '/videoJS/jquery.min' %> 
0

精彩评论

暂无评论...
验证码 换一张
取 消