search for: highest_bid

Displaying 2 results from an estimated 2 matches for "highest_bid".

2006 Jul 02
2
nil.- what the heck...
Okay first off here''s the error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.- Here''s the code in the model: def highest_bid @bid = nil @oldbid = 0 self.bids.each do |bid| if @bid == nil @bid = bid.max else if bid.max > @bid @oldbid,@bid = @bid,bid.max end end end @oldbid += 1 @dif = @bid - @oldbid if @oldbid != 0 @bid -= @dif if @oldbid != 0 @bid end Two questions: Is there an ea...
2006 Jul 06
2
@oldbid = 0 why?
Okay I''ve been working on a little biding system. In my model I have class Item < ActiveRecord::Base has_many :bids def highest_bid @bid = 0 self.bids.each do |bid| if @bid == nil @bid = bid.max else if bid.max > @bid @oldbid,@bid = @bid,bid.max end end end if @oldbid == 0 "#{@bid} - #{@oldbid+1} = #{@bid -= @oldbid+1}" else dif = @bid - @oldbid @bid -= dif end end end It...