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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:04:11+00:00 2026-05-12T12:04:11+00:00

I was wondering why when you create restful routes in rails with map.resources it

  • 0

I was wondering why when you create restful routes in rails with map.resources it generates actions for new, create, edit, update?
Is there anything wrong in declaring just one action for create and update
and do something like this?

def create
  unless post?
     @user = User.new
  else
     redirect_to :action => 'index' if user.create(params[:user])
  end
end

so we could have something like

:GET  users/create # to show the form (same as action - new)
:POST users/create # to create a new user

since Restful is based on verbs, wouldn’t this be the best approach to use?

Thank you for your attention

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

    I think there are two related but distinct issues here: the URLs exposed and the controller methods they are routed to. Since either of these could be changed independently, I’ll address them separately. Also, please note that I will be speaking a bit loosely, and strictly about REST as implemented in the context of Rails.

    In terms of the external URLs, I think it helps to distinguish between the URLs that make up the API of the system (:GET users/1, :PUT users/1, etc) and the URLs that are just there as a convenience to humans using a web browser (users/new, users/5/edit, etc). The API is all about fetching resources or interacting with them in some way – these are the URLs that another computer is going to use when interacting with your system. These URLs are typically just the address of the resource you want to interact with, and then you use the HTTP method and the parameters to indicate what it is you want to do (GET = show me this resource, PUT = change this resource, etc). The convenience URLs are there to display a form to make it easier for a human to use the API. You could edit a user by using curl to manually type out all the parameters you wanted to change and make a POST to users/1, but as a human it’s a lot easier if you can just use a form.

    To look at your examples above, then, :GET users/create might make sense (and is pretty similar to :GET users/new which is the default), but :POST users/create would roughly translate to “make a new one of users/create”, which doesn’t quite make sense.

    As far as the controller methods go, “new” and “create” are performing fundamentally different tasks, as should hopefully be clear from the previous paragraphs. One of them is displaying a form, and the other is creating a new resource. You could overload the same method to do this, of course, but without a compelling reason to do so, creating two small independent methods to handle two small independent tasks is probably a more natural approach.

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

Sidebar

Related Questions

We need to create a RESTful service. We're wondering which of the existing framework
Hi there i am wondering if i create a webapp that uses Spring AMQP.
I'm just wondering how you create a freestanding program in C++? Edit: By freestanding
I was wondering: is there a way to create HTML files programmatically in C#
I'm wondering how to create a new UIImage by overlaying one image overtop of
I am really new to .htaccess. I was wondering how to create a complex
I am looking to create a RESTFul PHP based API, and I am wondering
I was wondering how to create Code Editor Style in html page like this
I was wondering how to: create a droplet that saves to a relative filepath.
I was wondering how to create a strong key for AES-256 from the contents

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.