Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:29:28+00:00 2026-06-10T23:29:28+00:00

The author, Michael Hartl, says: Here the rule: get static_pages/home maps requests for the

  • 0

The author, Michael Hartl, says:

Here the rule:

get "static_pages/home"

maps requests for the URI /static_pages/home to the home action in the StaticPages controller.

How? The type of request is given, the url is given, but where is the mapping to a controller and action? My tests all pass, though.

I also tried deleting all the actions in the StaticPagesController, which just looks like this:

class StaticPagesController < ApplicationController
  def home
  end

  def about
  end

  def help
  end

  def contact
  end
end

…and my tests still pass, which is puzzling. No, I deleted all my actions like this:

class StaticPagesController < ApplicationController
end

The 2nd edition of the book(online) is really frustrating. Specifically, the section about making changes to the Guardfile is impossible to follow. For instance, if I instruct you to edit this file:

blah blah blah
dog dog dog
beetle beetle beetle
jump jump jump

and make these changes:

blah blah blah
.
.
.
go go go
.
.
.
jump jump jump

…would you have any idea where the line ‘go go go’ should be in the code?

And the hint for exercise 3.5-1 is flat out wrong. If the author would put up a comment section at the end of every chapter, the rails community could self-edit the book.

Tests:

require 'spec_helper'

describe "StaticPages" do
  let(:base_title) { "Ruby on Rails Tutorial Sample App" }

  describe "Home page" do
    it "should have the h1 'Sample App'" do
      visit '/static_pages/home'
      page.should have_selector('h1', :text => 'Sample App')
    end

    it "should have the title 'Home'" do
      visit "/static_pages/home"
      page.should have_selector(
            'title', 
            :text => "#{base_title} | Home")
    end

  end

  describe 'Help page' do
    it "should have the h1 'Help'" do
      visit "/static_pages/help"
      page.should have_selector('h1', :text => 'Help')
    end

    it "should have the title 'Help'" do
      visit '/static_pages/help'
      page.should have_selector(
            'title',
            :text => "#{base_title} | Help")
    end

  end

  describe 'About page' do
    it "should have the h1 'About'" do
      visit '/static_pages/about'
      page.should have_selector('h1', :text => 'About')
    end

    it "should have the title 'About'" do
      visit '/static_pages/about' 
      page.should have_selector(
            'title',
            :text => "#{base_title} | About")
    end
  end

  describe 'Contact page' do
    it "should have the h1 'Contact'" do
      visit '/static_pages/contact'
      page.should have_selector('h1', :text => 'Contact')
    end

    it "should have the title 'Contact'" do
      visit '/static_pages/contact'
      page.should have_selector(
            'title', 
            :text => "#{base_title} | Contact")
    end
  end

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:29:30+00:00Added an answer on June 10, 2026 at 11:29 pm

    I found an answer to this conundrum. First of all, this is a rails ‘problem’ not an rspec problem; if I add a route to routes.rb such as:

    get "static_pages/dog"
    

    …and then enter the url

    http://localhost:3000/static_pages/dog 
    

    in my browser, rails complains:

    Unknown action

    The action ‘dog’ could not be found for StaticPagesController

    Then if I add the dog action to the controller, then create a view,
    everything works fine and dandy.

    But if I then delete the dog action, and then use the same url,

    http://localhost:3000/static_pages/dog
    

    in my browser, this time I get a different result–instead of getting an error the view displays.

    As it turns out, that inconsistent behavior is a rails ‘feature’ called default rendering, explained here:

    http://guides.rubyonrails.org/layouts_and_rendering.html#rendering-by-default-convention-over-configuration-in-action

    According to the docs, all that’s needed to render a page is a route and a view–the action is optional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The author says here: http://java.dzone.com/articles/session-and-clustered-java-web that: With servlets, you have the power to put
The author of Searchlogic says that it is delegated to A::R converter, but at
I'm currently going through Michael Hartl's tutorial Ruby on Rails Tutorial http://ruby.railstutorial.org/ruby-on-rails-tutorial-book . I'm
I'm going through the tutorial on http://ruby.railstutorial.org/ by Michael Hartl. I'm on chapter six
I need to show author details on a page. Here is my typoscript to
in CSS: The missing manual the author says that font-size: medium (or other size
While going through Ruby On Rails Tutorial by Michael Hartl,in the section where the
Author, Committer and Pusher can be different person in Git, but git didn't store
The author wrote that whenever the value of point changes the value of myRect's
class Author { String name ArrayList<Book> books = [] static hasMany = [books: Book]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.