-1

I'm having a strange problem with css on rails. In app/views/search I have 2 files: index.html.erb and the other is result.html.erb. Their css are in public/css/results.css and public/css/index.css.

The problem is: One of them (index) loads its css, but the other no.

More informations:

  1. I'm also using a jquery theme, that is in app/asset/stylesheets and my app/view/layout/application.css is correct, addind the jquery.
  2. When i put the result.css on asset directory, it works. But it's not what i desire. I want this css only on the public folder
creativetechnologist
  • 1,452
  • 13
  • 29

1 Answers1

1

Have you tried placing a stylesheet_tag in your layout file (app/views/layouts/application.html.erb) with an absolute path?

<%= stylesheet_link_tag "/css/results.css" %>

Edit: Corrected the wrong method name.

adimitri
  • 1,296
  • 9
  • 13
  • Yes, as @adimitri said, you are going to need to add a stylesheet_tag for this style sheet. Anything under the assets directory is included automatically (which is why it worked when you put it there) but anything in the public directory is not included automatically. Any reason why your css isn't under assets/stylesheets? – Jeff Steil Dec 01 '11 at 14:52
  • Thanks for the help, adimitri. But when i put <%= stylesheet_tag "/css/results.css" %> in application.css but i got this error: – Rafael Mezzomo Dec 01 '11 at 17:40
  • undefined method `stylesheet_tag' for #<#:0x00000103c84728> – Rafael Mezzomo Dec 01 '11 at 17:40
  • You need to put that code in application.html.erb, which is your layout file for the application. You don't have access to ruby/rails methods in a .css or .js file in the app/assets/ directory. Typically you put the `stylesheet_tag` in between the tags. – adimitri Dec 01 '11 at 20:22
  • I have made a misstake. I've put this code in applicating.html.erb and then a got the error. – Rafael Mezzomo Dec 02 '11 at 14:13
  • Sorry, I had typed the wrong method name. It should be `stylesheet_link_tag`. I corrected it above. – adimitri Dec 02 '11 at 15:00