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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:01:25+00:00 2026-05-13T20:01:25+00:00

I need some help with this, please … If I save a transaction status

  • 0

I need some help with this, please …

If I save a transaction status as a code in the db, but I want to translate them to meaningful names how do I do that? Is that even recommended? If no, what would be an alternative to that?

For example:
in the db the statuses are “S”, “P”, “A”
and in the actual application I’d like to display: “Submitted”, “Pending”, “Approved” accordingly.

Thank you!

  • 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-13T20:01:25+00:00Added an answer on May 13, 2026 at 8:01 pm

    Say for example you have a model called Account in which you are storing the transaction status in a column called status whose value will be ione of the codes that you have mentioned, you can do

    class Account < ActiveRecord::Base
      TRANSACTION_STATUS = {
        "S" => "Submitted",
        "P" => "Pending",
        "A" => "Approved"
      }
    
      def status
        TRANSACTION_STATUS[self[:status]]
      end
    end
    

    By this way, your are overriding the method status provided by activerecord on Account object.

    Depending on how you are going to use the status field, you might be required to create proper index on those columns (for ex: if you are going to select accounts with pending transaction, etc)

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

Sidebar

Related Questions

I need some help, PLEASE LOOK AT EDIT 2 This is code of huffman:
I need some help with a LINQ query in VB.Net, please. I have this
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help with this please I can't get a handle on it.
i need some help. i have this code: <%= f.datetime_select :date, :start_year => 2011
I need some help with this accordion. Please see the demo here. http://jsfiddle.net/a36RL/ $(document).ready(function()
i really need some help on this. I searched the internet but couldn't find
Sorry, this question might sound silly, but I need some help! My project is
I'm pants at MySQL, so I really need some help with this, please: I
I need some help to put a simple php tag in this code $return.=<form

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.