On Jun 18, 5:22 pm, James Byrne <[email protected]>
wrote:

>
>   # save
>   #
>   # Override AR save method to catch DBMS specific errors
>   # such as uniqueness constraint violations
>   def save
>     super
>   rescue ActiveRecord::StatementInvalid => this_exception
>     errors.add_to_base(hll_ar_exception(this_exception))
>   end
>
> When I attempt to add a record in violation of a uniqueness constraint
> then hll_ar_exception catches the dbms error and returns.  If the error
> is something else then it raises the original error again.

You are using the return value of save. in the case when your rescue
block is invoked, the return value of save is what your rescue clause
evaluates to and it would seem that errors.add_to_base always
evaluates to something true. You need to return false from that block
(which your puts statement does since puts always evaluates to nil)

Fred

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to