Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use CSS with a ruby on rails application?

How do I use CSS with RoR? When I link externally, I'm never able to see the files. I cp'd the .css file to every folder I could think of...views, controller, template, and nothing seems to work.

What do I need to do to enable external CSS files with a rails application? I'm new to rails, so forgive me if this is basic.

like image 633
Stefan Kendall Avatar asked Apr 30 '09 00:04

Stefan Kendall


People also ask

Where do CSS files go in rails?

For Rails 3.1+ apps, you should use the asset pipeline. Place stylesheets in app/assets/stylesheets/ if they are specific to your application. You can also put them at vendor/assets/stylesheets/ if they are external (say if they are stylesheets for a javascript plugin.)

What is CSS Ruby?

CSS Ruby Layout is a module of CSS that provides the rendering model and formatting controls related to the display of ruby annotation. Ruby annotation is a form of interlinear annotation, consisting of short runs of text alongside the base text.


1 Answers

Put the CSS files in public/stylesheets and then use:

<%= stylesheet_link_tag "filename" %> 

to link to the stylesheet in your layouts or erb files in your views.

Similarly you put images in public/images and javascript files in public/javascripts.

like image 178
Kyle Boon Avatar answered Sep 28 '22 11:09

Kyle Boon