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*):(\d*)/ ).first
      self.hours = ( hrs.to_f + ( mins.to_f / 60.0 ) ).round(4)
    end
  end

____

However, the validation that triggers:

____
validates :hours, :presence => true, :numericality => { :greater_than => 
0, :less_than => 12 }
____

States that Hours is not a number.

So where is this 0.0 coming from? Is it even possible to get this value 
as a string if it's a Decimal in the database?

-- 
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 emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a1eab4e283ac003a4c3190f709a70bfa%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to