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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:49:42+00:00 2026-06-06T21:49:42+00:00

I am currently trying to put together a model structure for performing various calculations,

  • 0

I am currently trying to put together a model structure for performing various calculations, the formulas for which will be stored within the models.

Currently, I have an operand model, which is connected via many-to-many with the operations model. This works fine as long as I can always do a simple calculation (i.e. without intermediate steps).

Where I have a problem is if I need to (for example) subtract the result of one operation from the result of another. I’m aware that I could use a second model to perform calculations on operations, but I will run into the same problem further up the chain (i.e. if I need to perform an operation on the result of the calculation).

As such, what I need is essentially a way to nest the operations – i.e. an operation could take as its operands a normal operand from the operand model, or the result of another operation. Is there a way for the operations model to essentially self reference like this?

Thanks!

  • 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-06T21:49:44+00:00Added an answer on June 6, 2026 at 9:49 pm

    This is really more of an object modeling question than a rails question — and without understanding the domain models in more detail I’m not sure I can help a great deal.

    But as I think about calculators and how I’ve seen simple sets of operations/operand programming work, there have been a couple patterns I’ve seen that may be helpful:

    1. Do you have a ‘current result’ model that stores the results after each operation is performed? I’d think that each operation could be performed on a ‘current result’ model and it could store whatever the current result is.

    2. I’ve also seen situations where the idea of a ‘register’ was used as temporary storage for intermediate results. ‘store to register 1’, for example, would be an operation by itself. If you developed at ‘register’ object that you could store results into and fetch them from (or even that you could perform an operation on and leave the result in the register) that may be helpful.

    Does this make sense in your domain?

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

Sidebar

Related Questions

I'm currently fighting a fierce battle with an interface I'm trying to put together.
I am trying to put together a deployment package for a psolution which needs
I'm currently trying to put together a rich text editor that includes widgets from
Good evening guys! I'm currently trying to put together a CloudFlare client for the
I am currently trying to put together an URL where I specify some GET
I am currently trying to put together a simple Illustrator plugin, and coming from
I am currently trying to write some code that will accept some FTP details,
I'm currently trying to set up a secured folder with a few pages within
I'm trying to put together a form whereby users can update their 'email address'
I have been trying to put together something that allows me to extract points

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.