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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:45:14+00:00 2026-06-11T09:45:14+00:00

I am following a neat ruby on rails tutorial about routes. So I am

  • 0

I am following a neat ruby on rails tutorial about routes. So I am wondering, how does routing know so much?

I have one controller called posts_controller, and a post model. In the routes.rb file, I added

# config/routes.rb
resources :posts

As far as I understood it, this automatically creates the appropriate routings for all the controller actions associated with a post. So far, I have only one method in my posts_controller:

# app/controllers/posts_controller.rb
def index

end

But strangely, when I execute

$ rake routes

it gives me all this:

    posts GET    /posts(.:format)          posts#index
          POST   /posts(.:format)          posts#create
 new_post GET    /posts/new(.:format)      posts#new
edit_post GET    /posts/:id/edit(.:format) posts#edit
     post GET    /posts/:id(.:format)      posts#show
          PUT    /posts/:id(.:format)      posts#update
          DELETE /posts/:id(.:format)      posts#destroy

How does the routing mechanism know so much without ever telling it that I want to able to create and update posts?

  • 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-11T09:45:15+00:00Added an answer on June 11, 2026 at 9:45 am

    Using “resources” has nothing to do with the actions you have defined. It simply creates all of the restful routes you could need in your controller.

    As you can see it creates: index, create, new, edit, show, update, and destroy

    It’s actually unintelligent since it creates routes for actions which don’t exist.

    An example of how to limit it to only actions you need.

    resources :posts, :only => [:show, :index]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never found a neat(er) way of doing the following. Say I have
I have been trying to find a neat tutorial, guide or step by step
I have the following controller code that returns a Json list object to my
Consider the following definition: f[x_]=Piecewise[{{0,x<1/2},{Interval[{0,1}],x==1/2},{1,x>1/2}}]; Then when one does the Plot[f[x],{x,0,1}] of the function,
Following are the simple statements in the irb shell. What does nil in the
In my rails application my models have a to_html method. This method is called
I found a neat Ruby script to sum all purchases done on Amazon.de (no
The following UNIX one-liner looks for Python files below the CWD and adds them
I have the following class template: template<class T, unsigned N> class MyClass; where T
I've been following the rails edge guide in building a simple recipe app, and

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.