Paul Jonathan Thompson
2010-May-16 22:03 UTC
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-/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.
Jeffrey L. Taylor
2010-May-16 22:20 UTC
Re: A Ruby problem calculation problem - please help.
Quoting Paul Jonathan Thompson <rails001-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> 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. >Typo in program or e-mail: @bd_disC OR @db_disc? Jeffrey -- 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.
Paul Jonathan Thompson
2010-May-16 23:41 UTC
Re: A Ruby problem calculation problem - please help.
Sorry guys, I got this sorted. On 17 May 2010 10:03, Paul Jonathan Thompson <rails001-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.