Geraldo Lopes de Souza
2006-Jun-20 17:47 UTC
[Rails] Rails and decimal types mapped to float
Hi, I''m a brazilian developer, work in a hospital and we have a legacy database that we want to access via rails. Rails maps decimal types to float, and to circumvent this problem the suggestion one can find on the list is to represent decimal values as cents. That''s not applicable when you have to access a legacy database. I found two tickets 4274 and 4605 on rails trac, but they are open, without a word of David. Could you share how do you deal with this problem ? Sorry my english and thanks in advance, Geraldo Lopes de Souza -- Posted via http://www.ruby-forum.com/.
On Jun 20, 2006, at 6:47 pm, Geraldo Lopes de Souza wrote:> Hi, > > I''m a brazilian developer, work in a hospital and we have a legacy > database that we want to access via rails. > > Rails maps decimal types to float, and to circumvent this problem the > suggestion one can find on the list is to represent decimal values as > cents. That''s not applicable when you have to access a legacy > database. > > I found two tickets 4274 and 4605 on rails trac, but they are open, > without a word of David. > > Could you share how do you deal with this problem ? > > Sorry my english and thanks in advance, > > Geraldo Lopes de SouzaGeraldo, I wrote the patch on ticket 4274. The author of the patch for 4605 commented on it recently (unfortunatey I wasn''t aware of that ticket when I posted mine!) I also released a plugin version of the code on my website (www.ashleymoran.me.uk) for people who don''t want to patch a frozen Rails. We are now starting to develop Rails applications at the company I work for, so I will definitely be maintaining the code. Unfortunately the issue has not attracted the attention of DHH. It seems anyway that there is a frustratingly large number of people using Rails who don''t realise how critical proper decimal support is... just like there is a frustrating number of people who think foreign key constraints are optional in a database :-( The only issue I am aware of with my patch is that it doesn''t fix the scaffold generator, but I think that should be a minor change. If you are reading this David, what is your opinion on full decimal support? Is it likely to be included in Rails 1.2/2.0? Ashley
On Tuesday 20 June 2006 18:47, Geraldo Lopes de Souza wrote:> Hi, > > I''m a brazilian developer, work in a hospital and we have a legacy > database that we want to access via rails. > > Rails maps decimal types to float, and to circumvent this problem the > suggestion one can find on the list is to represent decimal values as > cents. That''s not applicable when you have to access a legacy database. > > I found two tickets 4274 and 4605 on rails trac, but they are open, > without a word of David. > > Could you share how do you deal with this problem ? > > Sorry my english and thanks in advance, > > Geraldo Lopes de SouzaJust an update on this... the author of patch 4605 has merged their code with mine (4274) into a new patch 5454, so looks like it is moving ahead now. This weekend I will turn the latest patch into a plugin so it can be used with Rails 1.1. Ashley
On Tuesday 20 June 2006 18:47, Geraldo Lopes de Souza wrote:> Hi, > > I''m a brazilian developer, work in a hospital and we have a legacy > database that we want to access via rails. > > Rails maps decimal types to float, and to circumvent this problem the > suggestion one can find on the list is to represent decimal values as > cents. That''s not applicable when you have to access a legacy database. > > I found two tickets 4274 and 4605 on rails trac, but they are open, > without a word of David. > > Could you share how do you deal with this problem ? > > Sorry my english and thanks in advance, > > Geraldo Lopes de SouzaJust an update on this... the author of patch 4605 has merged their code with mine (4274) into a new patch 5454, so looks like it is moving ahead now. This weekend I will turn the latest patch into a plugin so it can be used with Rails 1.1. Ashley -- "If you do it the stupid way, you will have to do it again" - Gregory Chudnovsky