spree/spree — pull request #1592 by pirj (2012-05-24 01:23:38+00:00)
Title:  "1 234.00 " cost_price validation failure coming from admin product controller

Please notice the difference of _before_type_cast (String vs Float)

1.9.3p125 :090 > m.class
=> Spree::Variant(id: integer, sku: string, price: decimal, weight: decimal, height: decimal, width: decimal, depth: decimal, deleted_at: datetime, is_master: boolean, product_id: integer, count_on_hand: integer, cost_price: decimal, position: integer)
1.9.3p125 :091 > m
=> #, weight: nil, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: true, product_id: 1073605631, count_on_hand: 15, cost_price: #, position: nil>
1.9.3p125 :092 > m.cost_price = "6 115.00 "
=> "6 115.00 "
1.9.3p125 :093 > m.price = "8 700.00 "
=> "8 700.00 "
1.9.3p125 :094 > m.save
(0.4ms) BEGIN
(0.3ms) ROLLBACK
=> false
1.9.3p125 :095 > m.errors
=> #, weight: nil, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: true, product_id: 1073605631, count_on_hand: 15, cost_price: #, position: nil>, @messages={:cost_price=>["is not a number"]}>
1.9.3p125 :096 > m.cost_price_before_type_cast
=> "6 115.00 "
1.9.3p125 :097 > m.price_before_type_cast
=> 8700.0

Please backport to master also