2

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 so that I can keep the JS and CSS together, and how do I reference them?

1 Answer 1

4

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' %> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.