Folks,
I’ve been following a ruby tutorial, at a step where I am trying to add some CSS to the pages.
ActionController::RoutingError (No route matches [GET] "/assets/blueprint/print.css"):
I believe my routes.rb file is messed up:
FirstApp::Application.routes.draw do
get "pages/home"
get "pages/contact"
get "pages/about"
root :to => "home#index"
application.html.erb file:
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
</head>
<body>
<%= yield %>
</body>
</html>
Directory structure on the server:
first_app% ls public
404.html 422.html 500.html downloads favicon.ico index.html.backup master.zip robots.txt stylesheets
[vasiliy@vbweb]~/ruby/first_app% ls public/stylesheets
blueprint
[vasiliy@vbweb]~/ruby/first_app% ls public/stylesheets/blueprint
ie.css plugins print.css screen.css src
You should check the tutorial you’re following, but it seems you following a slightly older tutorial (before the asset pipeline was added in Rails 3.1)
So things are a little different.
Stylesheets now are expected to live in
app/assets/stylesheetsIf you just move
blueprint/screen.cssandblueprint/print.cssinto that directory, it should start working.But… you may want to look at how the asset pipeline works, as it’s quite cool.
Take a look at
application.cssand you’ll see a few lines likeThis will require all files inside the stylesheets directory,
you can thereby just have a single line
stylesheet_link_tag :applicationwhich will do them all.However, that won’t do the print/screen media settings you’re trying to play with.