T
Tim
I'm at a loss for how to do this and I'm wondering if there is a way
without getting too complicated.
I'm using Rails 1.8.4, MYSQL 5 and AjaxScaffold.
I have accounts and every account has many (variable) months' worth of
data. I can easily pull up the account and then pull up the many
months of data no problem.
Each month has a dollar invested column and a percentage return
column. I have created a cumulative return column which is just the
following formula
@@unit_value = 100
def unit_value
if mymonthend == inception
@@unit_value = 100.to_f
else
@@unit_value =
@@unit_value*(1+Float(read_attribute("before_fee_return")))
end
end
cum_return = cum_return * (1+ percent_return)
It's basically a quick formula for showing the account's cumullative
performance over time.
The problem is each time I go to a new page, the cumulative return is
reset to 100. I want it to pick up where the last page left off. I
thought about putting the final cum return in a session variable but
that won't work if the user skips a page or goes back a page.
Is there any way to do this? Do I need to pass every month and every
cum return to a session variable array and look up the values every
time? Is that the only way to do it?
Right now I'm cheating by forcing all the data to show up on a page
but two things are wrong with this: 1) some accounts have hundreds of
months' worth of data; 2) for accounts with a lot of data it takes too
long to load a page.
Thanks in advance
without getting too complicated.
I'm using Rails 1.8.4, MYSQL 5 and AjaxScaffold.
I have accounts and every account has many (variable) months' worth of
data. I can easily pull up the account and then pull up the many
months of data no problem.
Each month has a dollar invested column and a percentage return
column. I have created a cumulative return column which is just the
following formula
@@unit_value = 100
def unit_value
if mymonthend == inception
@@unit_value = 100.to_f
else
@@unit_value =
@@unit_value*(1+Float(read_attribute("before_fee_return")))
end
end
cum_return = cum_return * (1+ percent_return)
It's basically a quick formula for showing the account's cumullative
performance over time.
The problem is each time I go to a new page, the cumulative return is
reset to 100. I want it to pick up where the last page left off. I
thought about putting the final cum return in a session variable but
that won't work if the user skips a page or goes back a page.
Is there any way to do this? Do I need to pass every month and every
cum return to a session variable array and look up the values every
time? Is that the only way to do it?
Right now I'm cheating by forcing all the data to show up on a page
but two things are wrong with this: 1) some accounts have hundreds of
months' worth of data; 2) for accounts with a lot of data it takes too
long to load a page.
Thanks in advance