Note that there are some explanatory texts on larger screens.

plurals
  1. PORails getting validation failed error, but no errors in ActiveRecord error model
    text
    copied!<p>I am having a problem with validation errors when saving a model using save!. The ActiveRecord error model error messages are blank, so i dont know what errors are happening on a validation attempt. When I try errors.full_messages or errors.each_full according to the <a href="http://ar.rubyonrails.org/classes/ActiveRecord/Errors.html">documentation</a>, it should display the errors, which it doesn't.</p> <p>The model I am trying to save is the Orders model (ecommerce site using Spree). When an item in the order gets deleted, update_totals! gets called which recalculates the totals, and then save! is called, which triggers the validation error (<strong>this error happens very rarely but only when I'm logged in</strong>, and I havent been able to find the cause of it). The order model has two validations in its model:</p> <pre><code> validates_numericality_of :item_total validates_numericality_of :total </code></pre> <p>i recorded order.item_total.inspect, order.total.inspect, and order.errors.full_messages.inspect and got this:</p> <pre><code>Wed Jan 25 08:53:08 -0800 2012order item total: #&lt;BigDecimal:15780c60,'0.279E2',8(16)&gt; Wed Jan 25 08:53:08 -0800 2012order total: #&lt;BigDecimal:152bf410,'0.2448225E2',12(20)&gt; Wed Jan 25 08:53:08 -0800 2012: ERRORS SAVING ORDER: Wed Jan 25 08:53:08 -0800 2012[] </code></pre> <p>item_total and total are stored in the mySQL database as decimal(8,2). The last line is order.errors.full_messages.inspect, which is an empty array. The validation error looks like this:</p> <pre><code>ActiveRecord::RecordInvalid (Validation failed: {{errors}}): vendor/extensions/mgx_core/app/models/order.rb:382:in `update_totals!' vendor/extensions/mgx_core/app/controllers/line_items_controller.rb:7:in `destroy' app/middleware/flash_session_cookie_middleware.rb:19:in `call' C:\Users\mgx\My Documents\Aptana Studio 3 Workspace\catalogue-spree\script\server:3 c:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_load' c:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_program' c:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/bin/rdebug-ide:87 c:/Ruby187/bin/rdebug-ide:19:in `load' c:/Ruby187/bin/rdebug-ide:19 </code></pre> <p><strong>I guess my question is twofold:</strong></p> <p><strong>1. Why is my activerecord errors model not saying what the validation error is?</strong></p> <p><strong>2. How do I fix this problem? Is my item_total and total valid for saving as decimal(8,2)?</strong></p> <p>I am using rails 2.3.5 and spree 0.10.2</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload