I need some input on the best approach. I have a model Property that
has some fields (price, down payment rate), then methods in
property.rb that compute derived information (down payment amount)
based on what the users input. Sounds simple enough.
I. PROBLEM
Here's where I need help: I want to make a "property calculator" of
sorts that takes a property, and allows users to input their numbers
without overwriting the current property to see how the outcome
(value) of the property/investment changes based on those numbers.
For example... the property saved in the database has a price of
100,000.00 and down payment rate of 10%. Derived information from
that: down payment is 10,000.00. In the property calculator, I want to
input 20% to see how the derived information will change, but I don't
want to save this into the property.
II. THE WAY I THOUGHT OF DOING IT
I know how to do it, but it's very tedious, and I know that once
something becomes tedious in Rails and I'm probably approaching things
wrong.
I was thinking of putting options in each of the methods in the
Property class. For example,
This sounds nice and simple enough at the start but I have many of
these derived methods and putting this options thing in all of them
would be a hassle.
I need some input on the best approach. I have a model Property that
has some fields (price, down payment rate), then methods in
property.rb that compute derived information (down payment amount)
based on what the users input. Sounds simple enough.
I. PROBLEM
Here's where I need help: I want to make a "property calculator" of
sorts that takes a property, and allows users to input their numbers
without overwriting the current property to see how the outcome
(value) of the property/investment changes based on those numbers.
For example... the property saved in the database has a price of
100,000.00 and down payment rate of 10%. Derived information from
that: down payment is 10,000.00. In the property calculator, I want to
input 20% to see how the derived information will change, but I don't
want to save this into the property.
II. THE WAY I THOUGHT OF DOING IT
I know how to do it, but it's very tedious, and I know that once
something becomes tedious in Rails and I'm probably approaching things
wrong.
I was thinking of putting options in each of the methods in the
Property class. For example,
This sounds nice and simple enough at the start but I have many of
these derived methods and putting this options thing in all of them
would be a hassle.
How do you suggest I approach this?
Thank you
Why would anything be saved back to the database in the first place? Or are you doing the math in your app rather than doing it in JavaScript?