I am using Rails 3.2.1. How do I add external style sheets in my rails application?
I’ve tried the following answers to no avail:
- How do I link to an external stylesheet in Ruby on Rails? – but the link given in the answer is not working.
- How do I use CSS with a ruby on rails application? – which says to add stylesheet in public/stylesheets, but I do not have folder named
public/stylesheets. I do have a public folder, but I have stylesheets folder under/vendor/assets. - css @import external style sheet – but it’s unclear.
I’m just going to assume you’re already using something like this in your layout:
stylesheet_link_tag 'application'If you want to refer to an external stylesheet then all you need to do is pass in the url.
stylesheet_link_tag 'application', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css'If you want to include the actual files in your codebase:
app/assets/stylesheetsis where you should place your main css files.vendor/assets/stylesheetsis where you should place the css files for any plugins that you might have.It’s the same for js files. For example your
application.jswould go inapp/assets/javascriptsand a jquery plugin liketimeago.jswould go invendor/assets/javascripts.