Skip to content

Instantly share code, notes, and snippets.

@mhfs
Created January 8, 2010 16:24
Show Gist options
  • Select an option

  • Save mhfs/272157 to your computer and use it in GitHub Desktop.

Select an option

Save mhfs/272157 to your computer and use it in GitHub Desktop.
class NFE < ActiveRecord::Base
validates_presence_of :service_value
usar_como_dinheiro :service_value
end
# >> n = NFE.new
# >> n.service_value = 10
# => 10
# >> n.valid?
# => true
# >> n.service_value = -50
# => -50
# >> n.valid?
# => true
# >> puts n.service_value
# 10,00
# => nil
# >> n = NFE.new
# >> n.service_value = "abc"
# => "abc"
# >> n.valid?
# => false
# >> n.service_value = 10
# => 10
# >> n.valid?
# => false
# >> puts n.service_value
# abc
# => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment