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

  • Home
  • SEARCH
  • 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 1087299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:55:13+00:00 2026-05-16T22:55:13+00:00

rails 3 newbie, with a general question about adding an additional route after scaffolding.

  • 0

rails 3 newbie, with a general question about adding an additional route after scaffolding.

I create a scaffold for books… Which works great, and provides a nice index page.

The Index page shows all books in the system,
I’d like to add a page ‘/books/yours’ that shows the books the user created. I already added the user_id to the books table, so that’s working when users create new books.
But I can’t figure out how to add the ‘yours’ page… Here’s what I did:

In the books_controller.rb added:

  def yours
        @books = Books.all

        respond_to do |format|
      format.html # yours.html.erb
     format.xml  { render :xml => @notes }
    end
  end

Then I added a views/books/yours.html.erb page with just an H1 tag that says bingo…

Then in routes.rb I added:

Cline::Application.routes.draw do

  resources :books
  devise_for :users
    match '/books/yours', :to => 'books#yours'
    root :to => 'pages#home'

But it doesn’t work? What’d I do wrong? thxs!

  • 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-05-16T22:55:13+00:00Added an answer on May 16, 2026 at 10:55 pm

    you could do this:

    resources :books do  
      collection do  
        get 'yours'  
      end 
    end 
    

    So the url looks like: /books/yours

    Here’s everything explained: http://edgeguides.rubyonrails.org/routing.html

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

Sidebar

Related Questions

(This is really a newbie question about Rake & Rails & dependencies in general.
Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
Rails newbie here. I have a list of items which can have a status
I'm a Rails newbie.... Here's what I'm trying to do.... I created a scaffold
Rails 3 newbie here... I'm working to create a devise auth system that like
rails 3 newbie, using Devise for auth... I want to create the following models:
Rails newbie, thanks for help with this hopefully basic JSON type question.... I have
I am a Rails newbie (from PHP). So forgive this basic data structures question:
I'm a Git newbie. I recently moved a Rails project from Subversion to Git.
Rails comes with a handy session hash into which we can cram stuff to

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.