I have a unique index constraint that throws an
ActiveRecord::StatementInvalid exception when triggered.  In my
application this causes a stack trace in the client browser.  I want to
rescue this error and handle it inside the controller, but I cannot seem
to.

Here is the controller code:

  def create
    @entity = Entity.new(params[:entity])
    ...
    respond_to do |format|
      if @entity.save
        flash[:notice] = 'Client was successfully created.'
        format.html { redirect_to(@client) }
        format.xml  { render :xml => @client,
          :status => :created, :location => @client }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @client.errors,
          :status => :unprocessable_entity }
      end
    end
  rescue => my_exception
    puts "Rescue clause invoked!"
    puts my_exception
  end


For now, all I want is to see the rescue clause invoked, but it is not.
have I put this clause in the wrong place? Am I specifying it wrong?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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