Sunday, May 16, 2010

[Rails] A Ruby problem calculation problem - please help.

I do not think that my problem is Rails but just my lack of
understanding of Ruby.

I am using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] and Rails 2.3.5

Code: First I evaluate @tot_hb to decide what discount is to be
applied. no problems here

if @tot_hb > 0
if @tot_hb > 399900
@bd_disc = 0.80
elsif @tot_hb > 199900
@bd_disc = 0.85
elsif @tot_hb > 99900
@bd_disc = 0.90
elsif @tot_hb > 49900
@bd_disc = 0.95
end
end

Then I attempt to update @client.bd_rate with the value that is in
@db_disc. @client.bd_rate is a MySql Decimal(3,2) field with a default
of zero

@client.bd_rate = @db_disc

At this point things go pear shaped and I get the message: nil can't
be coerced into Fixnum. I know that @db_disc has a value as if I do a
puts the value is displayed as 0.80

It would appear that it is some sort of conversion problem? Help would
be very much appreciated.

Regards,

Paul Thompson

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate