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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:23:22+00:00 2026-06-14T16:23:22+00:00

I have many methods in my models like this : def calc self.c =

  • 0

I have many methods in my models like this :

def calc
    self.c = self.child.a * self.child.b
end

I can easy use @object.calc to get the result et use it in others calculations.

My question is what is the best way to do that. Keep this or store it in my database and upload it for each child update. If the calculation use more complex functions (squareroot etc…) or if I have calculation of calculation, may be it would be faster to store it, or calculate it in my database request.

  • 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-14T16:23:23+00:00Added an answer on June 14, 2026 at 4:23 pm

    Depends on what you need it for. If it’s simple usage than calculating it on the fly might be an acceptable expense, to buy lower programmer time needed (a real benefit!).

    If you want to do any sort of filtering or ordering, then you’ll probably want to store it in a db column and use some sort of before_save hook to update the value.

    If it’s not a very expensive operation, like matrix multiplication, you might never notice the performance difference whichever way you go.

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

Sidebar

Related Questions

I have many js methods that uses global variables like: function DoSomething() { var
I have a class with many methods. How can I modify my methods so
I have a WCF service with many methods. I would like that after executing
I have an ActiveX/COM DLL. It contains many methods and properties. I would like
So I have an observer which looks like this: class RecipeObserver < Mongoid::Observer def
I have 2 models Category and Article related like this: class Category < ActiveRecord::Base
I have models of one of my projects set up to something like this
I have models like this: class User < ActiveRecord::Base has_many :cookies has_many :fortunes, :through
I have two models : class Game before_save :update_teacher teacher end def update_teacher teacher.update_attribute(something,
I have this class in a ruby on rails application class ChartData def self.user_logs_by_day(logs)

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.