[Rails] Setting Active Record Errors

Richard Williams
Fri, 17 Feb 2006 22:04:53 -0000

I''m creating an AR object in my controller and then attempting to add
error messages to it:


if (master_storeids.nil?)
  @item.errors.add_to_base ''No store is selected''
end


This works without error but when it comes time for AR to add the
record, it apparently initializes the errors because the message that I
added does not cause the AR add to fail as you would expect.

Even when there is a validation error in AR the message that I added
does not show up in the list of errors on the resulting page.

So, am I doing something wrong?   If not, how can I add my controller
errors to the AR errors so that they are reported on the resulting page
(and cause AR to not add the record)?


--
Posted with http://DevLists.com.  Sign up and save your time!