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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:38:32+00:00 2026-05-17T22:38:32+00:00

Just to simplify my question here: Update Geocode latitude and logitude everytime address is

  • 0

Just to simplify my question here: Update Geocode latitude and logitude everytime address is updated

I wanna do this:

Two input field for user to enter values for A, B. When it is saved, value A and B are saved to the database. In the database column, there is a column C, which dynamically C = A + B.

First save:

A = 1
B = 2
C = A + B = 3

Then when user updates value for A and B, C is also changed dynamically and replace the new sum value in the database.

A = 2
B = 2
Now C will calculate: C = A + B = 4

Now value C is 4 instead of 3.

Can anyone write this thing in Rails? 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-05-17T22:38:33+00:00Added an answer on May 17, 2026 at 10:38 pm

    I can!

    The key are callbacks. This will update C before you save the object.

    before_save :update_c
    
    def update_c
      self.c = a + b
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just found this out, so i am answering my own question :) Use a
I'll try to simplify and make clear my other question here. I am basically
Just looking for the first step basic solution here that keeps the honest people
just a quick question: I am a CS undergrad and have only had experience
so i have 4 divs (i actually have many more but this will simplify
Quick question/clarification required here. I have a DB table that will quite possibly have
Just learning about sql joins and things, and I have a question. Can you
This is an extension of a previous question I asked. I ran into some
This is an interesting question I am sure a lot of people will benefit
Actually this is a more specific version of a question I posted in past

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.