help stylesheet_link_tag

I was reading the book "Agile Web Development with Rails 4th Edition". In Chapter 11, Iteration C2: Adding a Page Layout 1 <!DOCTYPE html> - <html> - <head> - <title>Pragprog Books Online Store</title> 5 <%= stylesheet_link_tag "scaffold" %> - <%= stylesheet_link_tag "depot", :media => "all" %> - <%= javascript_include_tag :defaults %> - <%= csrf_meta_tag %> - </head>

"stylesheet_link_tag" and "javascript_include_tag" dosn't work. My Rails version is 3.2.1. The book was written using Rails 3.0.5. How to modify stylesheet_link_tag parameters to fit Rails 3.2.1?

My files

hj@debian:~/depot$ ls app/assets/stylesheets/ application.css depot.css products.css.scss store.css.scss carts.css.scss line_items.css.scss scaffolds.css.scss

hj@debian:~/depot$ ls app/assets/javascripts/ application.js depot.css products.js.coffee carts.js.coffee line_items.js.coffee store.js.coffee hj@debian:~/depot$

rails server outputs Started GET "/assets/scaffold.css" for 127.0.0.1 at 2012-03-01 09:44:21 +0800 Served asset /scaffold.css - 404 Not Found (5ms)

ActionController::RoutingError (No route matches [GET] "/assets/ scaffold.css"):   actionpack (3.2.1) lib/action_dispatch/middleware/ debug_exceptions.rb:21:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb: 56:in `call'   railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'   railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb: 22:in `call'   rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'   rack (1.4.1) lib/rack/runtime.rb:17:in `call'   activesupport (3.2.1) lib/active_support/cache/strategy/ local_cache.rb:72:in `call'   rack (1.4.1) lib/rack/lock.rb:15:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'   railties (3.2.1) lib/rails/engine.rb:479:in `call'   railties (3.2.1) lib/rails/application.rb:220:in `call'   rack (1.4.1) lib/rack/content_length.rb:14:in `call'   railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'   rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/ httpserver.rb:138:in `service'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/ httpserver.rb:94:in `run'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb: 191:in `block in start_thread'

  Rendered /home/hj/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/ action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms)

Started GET "/assets/defaults.js" for 127.0.0.1 at 2012-03-01 09:44:21 +0800 Served asset /defaults.js - 404 Not Found (5ms)

ActionController::RoutingError (No route matches [GET] "/assets/ defaults.js"):   actionpack (3.2.1) lib/action_dispatch/middleware/ debug_exceptions.rb:21:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb: 56:in `call'   railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'   railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb: 22:in `call'   rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'   rack (1.4.1) lib/rack/runtime.rb:17:in `call'   activesupport (3.2.1) lib/active_support/cache/strategy/ local_cache.rb:72:in `call'   rack (1.4.1) lib/rack/lock.rb:15:in `call'   actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'   railties (3.2.1) lib/rails/engine.rb:479:in `call'   railties (3.2.1) lib/rails/application.rb:220:in `call'   rack (1.4.1) lib/rack/content_length.rb:14:in `call'   railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'   rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/ httpserver.rb:138:in `service'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/ httpserver.rb:94:in `run'   /home/hj/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb: 191:in `block in start_thread'

hj wrote in post #1049623:

I was reading the book "Agile Web Development with Rails 4th Edition". In Chapter 11, Iteration C2: Adding a Page Layout

"stylesheet_link_tag" and "javascript_include_tag" dosn't work. My Rails version is 3.2.1. The book was written using Rails 3.0.5. How to modify stylesheet_link_tag parameters to fit Rails 3.2.1?

First of all I would suggest that if you're learning Rails from a book, then install the version of Rails that the book is using. It will save you a lot of headaches like this as you learn. Once you have a good handle on Rails then investigate the changes made in subsequent releases. There are release notes for each version that will explain things.

However, the easiest way to discover things like this is to generate a new project. Then generate a scaffold and go into the files and see what they use.

Example:

$ rails new demo $ cd demo $ rails g scaffold Person name:string

app/views/layouts/application.html.erb