"1 234.00 " cost_price validation failure coming from admin product controller #1592

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

pirj commented May 24, 2012

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
=> #<Spree::Variant id: 1073482949, sku: "COPY OF SWK2000/10", price: #BigDecimal:7140eb8,'0.817E4',9(18), weight: nil, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: true, product_id: 1073605631, count_on_hand: 15, cost_price: #BigDecimal:7140648,'0.6115E4',9(18), 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
=> #<ActiveModel::Errors:0x0000000705fdf0 @base=#<Spree::Variant id: 1073482949, sku: "COPY OF SWK2000/10", price: #BigDecimal:6fe9b50,'0.87E4',9(45), weight: nil, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: true, product_id: 1073605631, count_on_hand: 15, cost_price: #BigDecimal:6fe9448,'0.6E1',9(18), 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 1-1-stable also

@radar radar closed this in 7ab56f9 May 24, 2012

Member

radar commented May 24, 2012

Merged into 1-1-stable and master. Thanks!

mscottford pushed a commit to mscottford/spree that referenced this pull request May 24, 2012

tvdeyen pushed a commit to magiclabs/spree that referenced this pull request Jun 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment