I've set up application.html.erb to link to a stylesheet using the following code
<%= stylesheet_link_tag 'stylesheets/style', :media => 'screen' %>
However when I load the localhost in the browser window it prints this code
<link href="/assets/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
when I view the file directly I'm shown this error
Routing Error
No route matches [GET] "/assets/stylesheets/style.css"
I've read on some other questions that rails by default looks in public/stylesheets so I'm not sure why it's looking in assets?
I also tried to move the css file to the assets directory just to see if it would work however, it still doesn't work and gives the same routing error.
Been stuck on this for a couple of days and it's really doing my head in so appreciate any help you can give me.
Thanks in advance
Rails 3 comes with a new assets management which is actually one of the biggest pluses.
A guide on how it works is here
So if you have the application.css file in your assets/stylesheets you can simply drop the style.css in your assets/stylesheets directory renaming it in style.css.scss
In your view just leave:
<%= stylesheet_link_tag "application", media: 'screen' %>
Through sprockets the Rails app will load it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With