Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Order < ActiveResource::Base
- self.site = ''
- end
- o = Order.new(:price => 6.47)
- o.to_xml
- # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"float\">6.47</price>\n</order>\n"
- o = Order.new(:price => BigDecimal.new('6.47'))
- o.to_xml
- #=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"decimal\">6.47</price>\n</order>\n"
- # with the same precision you use
- o = Order.new(:price => BigDecimal.new('6.47', 4))
- o.to_xml
- #=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"decimal\">6.47</price>\n</order>\n"
Add Comment
Please, Sign In to add comment