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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:47:26+00:00 2026-06-15T03:47:26+00:00

What are the best practices to working with external IDs in REST API in

  • 0

What are the best practices to working with external IDs in REST API in general, and specifically in Rails?


Some Background:

I created an API for my application, which uses standard resource based JSON REST API.

I have a Flight model, by which users to create model objects by POSTing to /api/flights. This assigns a unique id to the new Flight objects the way ActiveRecord always does.

So far pretty standard.

However, my customer wants me to provide an option to assign an id by himself as part of the creation of the Flight object in the API, and later use the id he assigned in order to show/update/delete (etc.) the object by API.

I figure I can simply add an external_id parameter and add routes to update/delete/index by external_id. However, this seems to clutter the elegant resource based rails approach.

So, what’s the best practice?

  • 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-15T03:47:27+00:00Added an answer on June 15, 2026 at 3:47 am

    I think this is fine. Another similar case is creating a “slug” or “friendly url” for a URL which replaces the less friendly ID (“augments” is a better word than replaces). As long as the external_id is immutable, unique within its scope, URL-safe and so on it’s equivalent to the ID. Because it’s an external value, however, you need to confirm with your client that it is immutable; while possible to have it change, there’s a lot of work needed to handle changing the value (especially if it’s part of a URL).

    If you want to replace Rails’ find method to use the external_id instead, use method_missing to redefine id — there are examples of this around by googling “rails 3 slug method_missing” and similar.

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

Sidebar

Related Questions

What are the best practices regarding working with rich text in a web application?
What are some best practices to keep in mind when working extensively with SQLite
Working with rails 3.1 here. I'm wondering if there are any best practices for
I'm looking for a good summary of best practices for working with TFS source
I am looking for a PHP PDO full working example with best practices for
I have started working with enhanced for loops due to it's best practices and
What is best practice for C++ Public API? I am working on a C++
I'm working on an API wrapper class, which is the first I've made. For
I am currently working through the Gregory Brown Ruby Best Practices book. Early on,
Possible Duplicate: Anonymous vs named inner classes? - best practices? When working with Java

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.