CSS is not loading in app - ruby-on-rails

CSS won't load in my rails app. This is index.html.erb file located in view/products:
<h1>Listing products</h1>
<table>
<% #products.each do |product| %>
<tr class="<%= cycle('list_line_odd', 'list_line_even') %>">
<td>
<%= image_tag(product.image_url, :class=> 'list_image') %>
</td>
<td class="list_description">
<dl>
<dt><%= product.title %></dt>
<dd><%= truncate(strip_tags(product.description), :length=> 80) %></dd>
</dl>
</td>
<td class="list_actions">
<%= link_to 'Show', product %><br/>
<%= link_to 'Edit', edit_product_path(product) %><br/>
<%= link_to 'Destroy', product,
:confirm=> 'Are you sure?',
:method=> :delete %>
</td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New product', new_product_path %>
Then I have the application.html.erb file located in view/layouts. This file should link the css to html.
<!DOCTYPE html>
<html>
<head>
<title>Depot</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
My css file products.css.scss located in assets/stylesheets looks like this:
.products {
table {
border-collapse: collapse;
}
table tr td {
padding: 5px;
vertical-align: top;
}
.list_image {
width: 60px;
height: 70px;
}
.list_description {
width: 60%;
dl {
margin: 0;
}
dt {
color: #244;
font-weight: bold;
font-size: larger;
}
dd {
margin: 0;
}
}
.list_actions {
font-size: x-small;
text-align: right;
padding-left: 1em;
}
.list_line_even {
background-color: #e0f8f8;
}
.list_line_odd {
background-color: #f8b0f8;
}
}
And finally my my application.css file looks like this:
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
Everything looks okay to me and as I understand the application.css gathers up all the other css files so you don't have to link them all manually. Am I correct?
Also here is the server log when I load the page:
Started GET "/products" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Processing by ProductsController#index as HTML
Product Load (0.1ms) SELECT "products".* FROM "products"
Rendered products/index.html.erb within layouts/application (7.4ms)
Completed 200 OK in 26ms (Views: 24.2ms | ActiveRecord: 0.4ms)
Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /scaffolds.css - 304 Not Modified (0ms)
Started GET "/assets/all.css" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /all.css - 404 Not Found (4ms)
ActionController::RoutingError (No route matches [GET] "/assets/all.css"):
Rendered /Library/Ruby/Gems/1.8/gems/actionpack- 3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.5ms)
Started GET "/assets/products.css?body=1" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /products.css - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/products.js?body=1" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /products.js - 304 Not Modified (0ms)
Started GET "/assets/defaults.js" for 127.0.0.1 at Wed Dec 07 20:53:10 +0000 2011
Served asset /defaults.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/defaults.js"):
Rendered /Library/Ruby/Gems/1.8/gems/actionpack- 3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.9ms)
Why is my app not showing any CSS?

Do you have this in your ProductsController, or if absent, ApplicationController?
layout "application"
You've got a pre-asset pipeline <%= stylesheet_link_tag :all %> somewhere, which normally includes all stylesheets in /public/stylesheets, but it's telling asset pipeline to look for a file named all.css.
Since <%= stylesheet_link_tag :all %> is clearly not in your application.html.erb layout, some other layout is being rendered. Hunt it down, and/or ensure your controller(s) are calling the correct layout.

Run rake assets:precompile to compile and copy your css from /assets to /public (rails 3.1+)

I my case fixing an error in my style sheet and running:
$ RAILS_ENV=development rake assets:clean
has fixed the problem.
Running above command deletes your generated CSS files and forces rails to regenerate the CSS output from your Sass or SCSS files.

You might want to change your stylesheet link tag. I see you're currently using
<%= stylesheet_link_tag "application" %>
A freshly generated rails app should have the following two link tags which will automatically include all stylesheets and javascript:
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
But it seems to me that you're going along with the 'Agile Web Development with Rails Book', in which case, you might want to use the following:
<%= stylesheet_link_tag "scaffolds" %>
<%= stylesheet_link_tag "depot", :media => "all" %>
<%= javascript_include_tag "application" %>
I hope I could be of help to you, and to future readers of the Agile Web Development with Rails book who are going through the depot application example.

I stumbled upon the same problem while following the Agile Web Development with Rails book. Tried all the recommended solutions but to no avail.
Here's what worked for me:
In the aplication.html.erb file:
<!DOCTYPE html>
<html>
<head>
<title>Depot</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<!-- START_HIGHLIGHT -->
<body class='<%= controller.controller_name %>'>
<!-- END_HIGHLIGHT -->
<%= yield %>
</body>
</html>
The highlight is the important part.
Found the solution here: http://pragprog.com/titles/rails4/errata, where it says:
Sam Ruby says: http://pragprog.com/titles/rails4/source_code.
Hope it still helps.
Alex

Make controller a child of ApplicationController
To hook up your controller (and its views) to the pipeline, make sure your controller is a child of ApplicationController.
class ProductsController < ApplicationController
# all your code
end
Link to your root css file
Also make sure your application.html.erb has this line:
<%= stylesheet_link_tag 'application', media: 'all' %>
This adds the core application.css file to your views.
Add all css files through your root file
Finally make sure your application.css has this line:
*= require_tree .
If all those are in place, every file in app/assets/stylesheets/ will be included in the css pipeline.

well, modify the app/views/layouts/application.html.erb may work
change the "stylesheet_link_tag "application"" to "stylesheet_link_tag "depot"".
I wish it will help you!

Just got it to work. I had to place the depot.css file in app/views/assets/stylesheets (NOT the public directory, as it said in the book), and I changed the stylesheet link in application.html.erb to look like this:
<!DOCTYPE html>
<html>
<head>
<title>Depot</title>
<%= stylesheet_link_tag "depot"%>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

in your file 'layout.html.erb', the asset pipeline is getting the application.css only as you can read on your file application.html.erb.
I would try to add the line '#import "products"' in that application.css file.
Had the same issue and was able to fix it that way (using rails 4.1 though).

This might help someone looking this up. I had the similar issue. In my case css specified was being overridden by other css files properties.
Try adding this line to your application.html.erb.
<%= stylesheet_link_tag params[:controller] %>

Change index.html.erb
<table class="products">

It looks like you get this code from "Agile Web Development with Rails" book.
In this case perhaps one line is incorrect in app/views/layouts/application.html.erb:
change
<body>
to
<body class='<%= controller.controller_name %>'>
At least it works for me.

I faced the same problem, but I got my css to work... I just changed all the single quoted strings to double quotes in the index.html.erb file.
There is no need to change anything. I'm using rails 3.2.6

If you've compiled your assets once on your local machine to deploy it will make it so it will try to use those. You can use rake assets:precompile to update. Or you can go into your tmp folder (in the root of the rails app) and delete everything in cache/assets and cache/sass. Then after that you can go into /public/assets and delete everything with a hash after it (the random strings). Then restart the server. That is what worked for me.

From the book: Agile Web Development with Rails 4
on ~Page 72.
You'll find a small arrow next to the tag in the graphic.
With this change we are going to include the controller name in the <body class=""> so that the class name changes based on the controller.
In your SCSS file. "products.css.scss" is starting with styling the "CSS CLASS" for products. In our case it is .products with a bunch of styles nested inside it.
A small change that basically prevents the .products class from being applied to the body, which in turn prevents the rest from being styled as well.

It's late and maybe I missed something, what do you mean for "CSS won't load in my rails app"? If you view the page source code in your browser do you see the stylesheet link elements of your application? Is your table styled as aspected?
From what I see in the server log:
Started GET "/assets/products.css?body=1" for 127.0.0.1 at Wed Dec 07 [...]
Served asset /products.css - 304 Not Modified (0ms)
Your application is using the CSS files.
BTW, as you said the application.css "load" the other CSS files, this is done using require_tree.

I was having this same issue with Rails 3.2.0 with ruby-2.0.0-p247. I tried every suggestion in this thread. I have no idea why, but switching to Rails 3.2.12 fixed it.

The problem for me (with Rails 7.0.4) was that I had a local public/assets folder. After this was removed it was working again. "If precompiled assets are available, they will be served — even if they no longer match the original (uncompiled) assets, even on the development server."

Related

Routing issues on ruby in rails 4.2.6?

When I am trying to perform destroy action n windows 7, I am receiving:
Started GET "/stylesheets/default.css" for ::1 at 2016-06-20 13:52:53 +0530
ActionController::RoutingError (No route matches [GET] "/stylesheets/default.css"):
and
Started GET "/javascripts/default.js" for ::1 at 2016-06-20 13:52:59 +0530
ActionController::RoutingError (No route matches [GET] "/javascripts/default.js"):
use "application" instead of "default" in
views/layouts/application.html.erb
<%= stylesheet_link_tag "application", media: "all" %>
The type of the request, i.e. delete, is irrelevant.
Edit:=================
Your error is due to the fact that your stylesheet_link_tag on the page views/layouts/application.html.erb looks something like this:
<%= stylesheet_link_tag "default", media: "all" %>
but there is no file by the name of default.css in assets/stylesheets--presumably the default file application.css contains the manifest for the css files.
====================
The rails asset pipeline combines all the css files listed in the manifest file assets/stylesheets/application.css into one big file, minimizes it, then sends the single css file to the browser when a view is loaded. The same thing happens for all your js files. To properly link to your single, minimized css file and your single minimized js file, the views/layouts/application.html.erb file should look something like this:
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
<%= stylesheet_link_tag "application", media: "all" %> #<****HERE
<%= javascript_include_tag "application" %> #<****HERE
<%= csrf_meta_tags %>
</head>
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<div>
<%= yield %>
</div>
<%= debug params %>
<%= debug session[:allowed] %>
</body>
</html>
When the page loads in your browser, you will see requests in your server window like:
Started GET "/assets/cats.css?body=1" for 127.0.0.1 at 2016-06-20 04:06:19 -0600
Started GET "/assets/cats.js?body=1" for 127.0.0.1 at 2016-06-20 04:06:19 -0600
You can use the path:
/stylesheets/default.css
in your stylesheet_link_tag if the file:
public/stylesheets/default.css
exists. According to the rails asset pipeline guide, you also have to add:
config.serve_static_files = true
to config/application.rb--but I find that is not needed for development, so it's probably required for production.
The server window does not show a request for a css file located in the public/ directory, but you can open a web inspector and examine the network activity and see that your browser does send the request.
Have you given the method for the delete action to be performed, because i think if you don't provide the exact method , which in case of your's is DELETE it would redirect to some other paths. If you can provide the syntax you are using for this , it will be more helpful to resolve the issue. For eg:-
<%= link_to '', your_action_path(object.id),:class=>"btn btn-danger fa fa-trash-o fa-1x",:style=>"margin-top:4px",:confirm =>'Are you sure',:method => :delete %>

Restructuring .js files and directories

When I recently started on a mobile version of my app I realized that I had no use of all javascript code written for desktop clients. So I put this in application.html.erb
<% if mobile_agent? %>
<%= javascript_include_tag "mobile" %>
<%= stylesheet_link_tag "mobile", :media => "all" %>
<% else %>
<%= javascript_include_tag "desktop" %>
<%= stylesheet_link_tag "desktop", :media => "all" %>
<% end %>
And in app > assets > javascripts I created this structure
- desktop.js
- mobile.js
- desktop/file1.js
- desktop/file2.js
- mobile/file1.js
- mobile/file2.js
- shared/file1.js
- shared/file2.js
And in mobile.js:
//= require_tree ./mobile
//= require_tree ./shared
And in desktop.js
//= require_tree ./desktop
//= require_tree ./shared
In development env that has worked fine, but when I have deployed to Heroku it gives me an error:
Completed 500 Internal Server Error in 100ms
ActionView::Template::Error (mobile.js isn't precompiled):
8: <meta name="format-detection" content="telephone=no">
11: <%= javascript_include_tag "mobile" %>
9:
12: <%= stylesheet_link_tag "mobile", :media => "all" %>
10: <% if mobile_agent? %>
Parameters: {"community_category"=>"swingdancing", "city"=>"stockholm"}
app/views/layouts/application.html.erb:11:in 78182492067426179_45617280'
13: <% else %>
Completed 500 Internal Server Error in 2ms
app/controllers/communities_controller.rb:20:in `show'
Processing by ErrorsController#show as HTML
14: <%= javascript_include_tag "desktop" %>
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/helpers/rails_helper.rb:142:in Error during failsafe response: mobile.js isn't precompiled
What is causing this error and how can I resolve it?
what to do ?
simply add
config.assets.precompile += %w(mobile.js)
to config/application.rb
why ?
when you deploy to production environment, by default rails uses the asset pipeline.
This means that instead of serving directly the files that are in assets/, rails assumes that you have run rake assets:precompile beforehand, and that there are concatenated, compressed and minified versions of your assets in an another folder.
This implies that each and every asset you intend to load from the browser should be precompiled. The benefit is that instead of serving many human-readable files, you only serve a few that have been minified - less connections, less volume = faster load time.
This feature is inactive in development mode because you would have to recompile the assets at each request, and moreover being able to read js and css is quite usefull for debugging.

generating pdf hangs on rails 4 using PDFkit gem

I'm able to download pdf file with:
curl google.com | wkhtmltopdf - test.pdf
so it means, wkhtmlpdf installation was successful.
But, when I try to generate pdf file by accessing http://localhost:3000/contacts/1.pdf it hangs. In the status bar it shows: Waiting for localhost...
Rails server output:
Started GET "/contacts/1.pdf" for 127.0.0.1 at 2013-07-28 21:45:06 +0900
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by ContactsController#show as HTML
Parameters: {"id"=>"1"}
Contact Load (0.3ms) SELECT "contacts".* FROM "contacts" WHERE "contacts"."id" = ? LIMIT 1 [["id", "1"]]
Rendered contacts/show.html.erb within layouts/application (1.4ms)
Completed 200 OK in 99ms (Views: 57.0ms | ActiveRecord: 0.7ms)
Gemfile:
gem 'pdfkit'
application.rb:
config.middleware.use "PDFKit::Middleware"
According to the PDFKit railscast this should be enough for generating pdf files just by adding .pdf ...
UPDATE:
show.html.erb:
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= #contact.name %>
</p>
<p>
<strong>Age:</strong>
<%= #contact.age %>
</p>
<%= link_to 'Edit', edit_contact_path(#contact) %> |
<%= link_to 'Back', contacts_path %>
layouts/application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>Pdftest</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
UPDATE 2:
Thanks to #Arman H for helping me to figure out that I have to specify absolute path for assets instead of a relative ones. When I removed the following lines I was able to generate PDF file:
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
Now, I can't get how to substitute this with an absolute paths. It seems this post is what I need, but I still can't figure out how this would look like for my case.
The issue was due to stylesheet_link_tag and javascript_include_tag using relative URLs, which often causes wkhtmltopdf to hang when loading assets from the same server that wkhtmltopdf is running on.
Using absolute URLs for assets solved the problem.
Set asset_host in Rails' config, which also affects stylesheet_link_tag and javascript_include_tag:
# Modify asset host config setting in `config/application.rb`
# Or create a new initializer: `config/initializers/wkhtmltopdf.rb`
config.action_controller.asset_host = "http://mysite.com"
# Or you can have different hosts for development (local) and production (CDN):
# In `config/environments/development.rb`
config.action_controller.asset_host = "http://localhost"
# In `config/environments/production.rb`
config.action_controller.asset_host = "http://d111111abcdef8.cloudfront.net"
Setting config.action_controller.asset_host = "http://localhost"
in development.rb actually didn't work for me. That is, the PDF generation would work, but then assets wouldn't come through when rendering HTML.
I followed the method here: http://jguimont.com/post/2627758108/pdfkit-and-its-middleware-on-heroku
and it worked like a charm for me. Hope this helps someone. Just throw assets.rb in config/intializers and you're good to go.
I had the same issue in which my log showed the page had rendered however no pdf was generated and the browser would hang. It ended up having nothing to do with OS compatability, missing librariers, gems nor dependencies but instead I needed to raise the max allowable thread count for my Puma server (which had been set to 1) upto 2 or more. This then generated pdf's as normal.

I didn't set path for css, but the css effect is working , why?

There is nothing in application.css.
I have put a file named "cake.generic.css" in app/assets folder. If i load the home page the cake.generic.css is loading and working staraightway. Why is it working. I didn't set this path in application.html.erb.
<head>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
In Rails 3.1, there is an asset pipeline (check Rails guides).
Basically, in your application.css, all css files are required by default. It lets you have a nice unique and compressed file in production
check this:
http://railscasts.com/episodes/279-understanding-the-asset-pipeline
http://railscasts.com/episodes/282-upgrading-to-rails-3-1

Rails custom css links are not working - following tutorial in http://ruby.railstutorial.org

I'm new to rails and working my way into the tutorial here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
I've added the blueprint css package to the public/stylesheets directory and added a custom.css file however I cannot seem to get the stylesheet to load. From my understanding fo the setup the page should have a blue background and some other small changes.
In my app/views/layouts/application.html.erb file I've added the following line:
<%= stylesheet_link_tag 'stylesheets/custom', :media => 'screen' %>
Which I believe should cause the css from the /public/custom.css to load.
In the tutorial the content of the custom.css file is located in section 5.1.2 (sorry I'm only able to post 2 hyperlinks here)
.
And the content of the app/views/layouts/application.html.erb file is here:
http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec:adding_to_the_layout
When I view source on the page there is a link to the custom.css file here:
But clicking that brings up a "Routing Error - No route matches "/stylesheets/stylesheets/custom.css"" message.
As far as I can find I've followed the tutorial exactly so I'm not sure what is wrong or what I've missed. Any help on where to go from here would be appreciated.
complete text of the application.html.erb file:
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
<%= stylesheet_link_tag 'custom', :media => 'screen' %>
</head>
<body>
<div class="container">
<header>
<%= image_tag("logo.png", :alt => "Sample App", :class => "round") %>
<nav class="round">
<ul>
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
</header>
<section class="round">
<%= yield %>
</section>
</div>
</body>
</html>
This still has the same error when clicking the custom.css link in source as before:
"Routing Error - No route matches "/stylesheets/stylesheets/custom.css""
is this happening on localhost or production environment? If it's production then open config/production.rb and change:
config.serve_static_assets = false
to
config.serve_static_assets = true
If this is happening in development environment then I'm wondering if you possibly have more than 1 layout file. Check to make sure you don't have application.html.erb and application.html.haml. It's also possible that you have a separate layout for your posts, which would be titled post.html.haml or something...
ALSO
you state the following:
Which I believe should cause the css from the /public/custom.css to load.
If your custom.css file is located in public/custom.css then it is in the wrong place, it should be in public/stylesheets/custom.css
EDIT:
below is a screenshot of your app as it appears on my machine, it looks like it works ok after moving stylesheet into the right folder. I also took the liberty of deleting public/index.html, but you can leave it in for now until the tutorial advises you to take it out
Change it to stylesheet_link_tag 'custom', :media => 'screen'. It will automatically look in the /public/stylesheets/
So I'm not sure if you ever figured this out (I'm sure you did), but I just had the same issue, and found a solution. It looks like rails is looking in /app/assets/stylesheets instead of /public/stylesheets. I'm not sure if this is the correct way it should be working, but I moved my custom.css file there and everything is now working fine.
I had a similar problem following the tutorial but it hit me in chapter 4 where we first include the helper for the blueprint css files. I am using Rails v. 3.1.3, and for me nnaficy's answer solved the problem. Heres the description of why this is happening from the rubyonrails guide :
(source: http://guides.rubyonrails.org/layouts_and_rendering.html)
"3.1.2 Linking to JavaScript Files with the javascript_include_tag
The javascript_include_tag helper returns an HTML script tag for each source provided.
If you are using Rails with the Asset Pipeline enabled, this helper will generate a link to /assets/javascripts/ rather than public/javascripts which was used in earlier versions of Rails. This link is then served by the Sprockets gem, which was introduced in Rails 3.1."
(i copied the above for the explanation, but specific to css is the following snippet:)
"3.1.3 Linking to CSS Files with the stylesheet_link_tag
The stylesheet_link_tag helper returns an HTML tag for each source provided.
If you are using Rails with the “Asset Pipeline” enabled, this helper will generate a link to /assets/stylesheets/. This link is then processed by the Sprockets gem. A stylesheet file can be stored in one of three locations: app/assets, lib/assets or vendor/assets."
so instead of copying my blueprint folder to public/stylesheets/, i copied it to app/assets/stylesheets/ and the css did its magic.
Change the line:
<%= stylesheet_link_tag '/stylesheets/application', :media => 'screen' %>
to
<%= stylesheet_link_tag '/stylesheets/custom', :media => 'screen' %>
It worked for me.
Also, for those who are still working on the problem, check that you are puting the CSS in the right project. I had a folder called "sample_app" in which I started the tutorial. Some days after, I started using Aptana/RadRails, which created a custom project folder (workspace). I didn't realized and put all my css in my initial "sample_app" folder. That's why Rails could not find the css/logo!
Same question with my current Rails 3.2.6 app. I've solved it with this include function:
<%= stylesheet_link_tag '/stylesheets/custom', :media => 'screen' %>
You have to use absolute path's instead of relative ones.
Ok so maybe someone out there is still struggling, I've been trying to figure these out for a while now and i have solved the problem. Like #shime is saying Rails looks in public/stylesheets.
application.html.erb
-----------------
`<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<%= stylesheet_link_tag **'screen'**, :media => 'screen' %>
<%= stylesheet_link_tag **'print'**, :media => 'print' %>
</head>
<body>
<%= yield %>
</body>
</html>`
Move screen.css and print.css from stylesheet/blueprint to app/assets/stylesheets.

Resources