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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:44:40+00:00 2026-05-25T09:44:40+00:00

For certain models, I wish to provide functionality that allows a user to create

  • 0

For certain models, I wish to provide functionality that allows a user to create a new record with default attributes based on copy of an existing record.

I’m wondering what would be the correct restful route for this.

My initial thinking is that it could be a parameter to the new action. I.e. to borrow from the the Rails Guides examples, instead of just:

GET : /photos/new

Also allow:

GET : /photos/new/:id

…where :id is the id of the record to use as a template. The response would be a new/edit form, same as with a plain old new but the values would be pre-filled with data from the existing record. The parameter (or absense of it) could be easily handled by the new controller method.

The alternative seems to be to create a new controller method, for example copy which would also accept an id of an existing record and response with the new form as above. This seems a little ‘incorrect’ to me, as the record is not actually being copied until the user saves the new record (after probably editig it somewhat).

TIA…

UPDATE: my question is not “how do I do this in rails?”, it’s “is it RESTful?”

  • 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-25T09:44:40+00:00Added an answer on May 25, 2026 at 9:44 am

    my question is not “how do I do this in rails?”, it’s “is it RESTful?”

    No, it isn’t. For that matter, neither is GET /photos/new. Rails seems to be hopelessly mired in the past, where it was considered haute programme for a GET on a URI to return an HTML form which would then POST x-www-form-urlencoded data back to that same URI. The opacity of that POST forces them to invent new verbs-as-URI’s like /photos/new, when you could be using PUT instead, or at least POST with the same media type.

    The simplest way to make a copy of an HTTP resource RESTfully is:

    GET /photos/{id}/ -> [representation of a photo resource]
    ...make modifications to that representation as desired...
    POST /photos/ <- [modified representation]
    

    If you’re implementing this for browsers, you should be able to perform those actions via Ajax quite easily, using an HTML page sitting perhaps at /photos/manager.html/ to drive the interaction with the user.

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

Sidebar

Related Questions

Under certain circumstances, I wish to display an error message to the user if
Given the following two models: class Card(models.Model): disabled = models.BooleanField(default=False) class User(models.Model): owned_cards =
I'm attempting to have inherited class templates, so that all my models have certain
Rails models come with certain built-in methods like this: Appointment.new Appointment.find(1) How do I
I wrote a certain function that I'd like all my Django models to have.
Can I take the .save method of certain activeRecord models and add functionality to
I've got a series of Post models that hasAndBelongsToMany Media models. In certain function
I have 2 models, say Model A and Model B, each one having certain
I have many models, let's say Model1, Model2 and Model3. I have a certain
I'm trying to write a behavior that will give my models access to a

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.