I have a partial form for tank tickets that requires end user
input...It is designed to minimize said input to reduce the
possibility for error...There are several other fields where
calculation results need to go before being sent to the database...!
Questions:
1) Is the ''Create'' function the place to trigger the
calcs...?...How...?
2) Where is the best practice location for the calcs...?...(model,
helper...?...)
3) How do I get the results into the database so they can be
displayed later on...?
Example:
User input fields...
1) A drop-down to select a tank number
2) Drop-downs to select a date
3) A Text field to input a ticket number
4) A drop-down to select a product type
5) A Text field to input an API gravity
6) A Text field to input a tank temperature
7) A Text field to input the tank gauge
The remaining five fields are calculated:
8) Gross Volume (each tank in the database has an ''increment
table''
used to determine the gross volume using the ''gauge'')
9) Volume Correction Factor (calculated from the API gravity and the
tank temperature)
10) Roof Correction Factor (this is calculated using data from the
''tanks'' table)
11) Net Volume (this is the result of multiplying the Gross Volume by
the Volume Correction Factor then adding the Roof Corr)
12) Ticket Volume (this is determined by comparing this ticket ''Net
Volume'' to the last tickets ''Net Volume'' for the same
tank)
I have all the calculations running in rails and they are returning
the correct results...
So far, the only way I can get all this to work is to have the look-up
methods in the ''public_helper'' and the raw calcs in the
''application_helper''...
Here''s an example of how I''m getting the ''gross
volume'':
def get_gross_vol( gauge )
@upperinc = Tank202increment.find(:first, :conditions =>
["inc>= ?", gauge])
@lowerinc = Tank202increment.find(:first, :conditions => ["inc <
?",
gauge], :order => ''inc DESC'')
gross_vol = ((gauge - @lowerinc.inc) * 100 * @upperinc.multiplier) +
@lowerinc.volume
gross_vol = round(gross_vol, 2)
return gross_vol
end
Here''s a calculation example:
# Calculate Density(kg/m3)
# Inputs:
# Observed API gravity
def get_density( api )
density = (141.5 / (131.5 + api.to_f) * 999.012)
density = round(density, 3)
return density
end
Thanks in advance for any light shed on this...I am new to Rails...am
luvin'' it and am trying to get it right...especially with regard to
''Best Practices''/''Standardization''...!
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.