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 3501274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:50:19+00:00 2026-05-18T12:50:19+00:00

I am having another ruby nuby moment and can’t seem to wrap my head

  • 0

I am having another ruby nuby moment and can’t seem to wrap my head around this simple problem.

I have this as a route:

resources :pages

I have this in my pages controller:

def testy

end

and I have this in app/views/pages/testy.html.erb

<h1>Testy</h1>

I am trying to access the page like so: http://localhost:3000/pages/testy

And I get the following error:

Couldn't find Page with ID=testy

Here is the log:

Started GET "/pages/testy" for 127.0.0.1 at Thu Dec 09 14:24:51 -0600 2010
Processing by PagesController#show as HTML
Parameters: {"id"=>"testy"}
[1m[35mPage Load (0.3ms)[0m  SELECT "pages".* FROM "pages" WHERE ("pages"."id" = 0) LIMIT 1
Completed   in 12ms

ActiveRecord::RecordNotFound (Couldn't find Page with ID=testy):
app/controllers/pages_controller.rb:11:in `show'

It’s obvious by the log that it’s trying to access #show, but why? I think it’s a problem with my route. Can someone give me a quick pointer?

I was following the Rails Guides here and I think this is what is throwing me off “… the rule is that if you do not explicitly render something by the end of the controller action, rails will look for the action_name.html.erb template in the controllers view path and then render that, …”

  • 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-18T12:50:20+00:00Added an answer on May 18, 2026 at 12:50 pm

    When you set up a RESTful route like resources :pages, by default anything after pages/ in the URL is put into the params hash as an ID so pages/1 would give you a params hash that includes {:id => '1'} (among other things like :controller, :action, etc.).

    There is an exception for certain actions like pages/new or pages/edit . Rails is smart enough to know that ‘new’ and ‘edit’ are not IDs. You just need to tell rails that ‘testy’ is not an ID either.

    You can define custom actions using member or collection inside a block attached to resources like this:

    resources :pages do
      collection do
        get :testy  # will match pages/testy
        get :foo
        post :bar
      end
    
      member do
        get :baz # will match pages/1/baz
      end
    end
    

    Now rails will know that pages/testy is a custom route and will not interpret ‘testy’ as an ID. Make sure your route names are never the same as your ID. In other words, if you had a Page that had an id of testy for some reason, you’d never be able to reach it given the above routes!

    For deeper knowledge, I highly recommend the official rails guide on routes:
    http://guides.rubyonrails.org/routing.html

    Kind of long, but definitely worth the time to read.

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

Sidebar

Related Questions

I am having another problem with my android app which I can't find an
After getting the right answer from this question , I am having another problem
having another problem with my javascript for my table. Basically, if you look at
I saw the other topic and I'm having another problem. The process is starting
As many of you may already know I have been having issues with another
I'm having problems with Ruby scripts finding the right gems. It seems this is
I just moved a project to another server and seem to be having problems
New to Ruby on Rails and having a problem when following Michael Hartl's tutorial.I'm
i developed a project using Ruby on Rails and i having a huge problem
I have a 'div' container 'obj_image' having another 'div' 'like_icon' which if the user

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.