# errors.add\_to\_base not actually adding any errors to base?

**URL:** <https://discuss.rubyonrails.org/t/errors-add-to-base-not-actually-adding-any-errors-to-base/23214>\
**Category:** rubyonrails-talk\
**Created:** [January 14, 2008, 11:18pm UTC](https://discuss.rubyonrails.org/t/errors-add-to-base-not-actually-adding-any-errors-to-base/23214 "2008-01-14T23:18:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff7](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jeff7](https://discuss.rubyonrails.org/u/Jeff7)\
**Post date:** [January 14, 2008, 11:18pm UTC](https://discuss.rubyonrails.org/t/errors-add-to-base-not-actually-adding-any-errors-to-base/23214/1 "2008-01-14T23:18:51Z")

</div>

I checked the API docs and found nothing about add\_to\_base gotchas.. but when adding an error to the base of an ActiveRecord object, it essentially does nothing. The save/valid? methods work as if there were no errors, and of course the view does not display them. Code basically goes like this:

@order = account.orders.build @order.errors.add\_to\_base("Must select at least one item") if @order.save ...

also tried @order.valid? instead of save

Both return true and the record is saved anyway. Any ideas? I am running Rails 1.2.6 as a gem.

---

<div class="post-metadata">

**Author:** ![Jeff7](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jeff7](https://discuss.rubyonrails.org/u/Jeff7)\
**Post date:** [January 15, 2008, 3:09am UTC](https://discuss.rubyonrails.org/t/errors-add-to-base-not-actually-adding-any-errors-to-base/23214/2 "2008-01-15T03:09:32Z")

</div>

I figured this out. The "save" and "valid?" methods call errors.clear before running, which was dumping the errors I had added.

Should have thought to put it in the model anyway, it is business logic after all. This works:

def validate &nbsp;&nbsp;if items.empty? &nbsp;&nbsp;&nbsp;&nbsp;errors.add\_to\_base("Must select at least one item.") &nbsp;&nbsp;end end
