Thanks for the tip! If the call to "super" triggers the validation then
that should be perfect.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving
On Tuesday, 25 June 2013 05:15:06 UTC-7, Ruby-Forum.com User wrote:
>
> Catching that 0.0 value was the right direction to look in:
>
> def convert_hours
> if hours_before_type_cast && hours_before_type_cast =~ /:/
> hrs, mins = hours_before_type_cast.scan( /(\d*):(\d*)/ ).first
>
Catching that 0.0 value was the right direction to look in:
def convert_hours
if hours_before_type_cast && hours_before_type_cast =~ /:/
hrs, mins = hours_before_type_cast.scan( /(\d*):(\d*)/ ).first
self.hours = BigDecimal( ( hrs.to_f + ( mins.to_f / 60.0 ) ), 4 )
end
end
I've managed to get the event to fire now, but what I get from STDOUT is
0.0
So I guess that means I'm not receiving a string from input.
before_validation :convert_hours
protected
def convert_hours
STDOUT << hours
if hours && hours =~ /:/
hrs, mins = hours.scan( /(\d*)
4 matches
Mail list logo