Sha256: b216feef8b407227a60ac96ccb0e8d6875e3668dcc49a44a3d6eedb2be313255
Contents?: true
Size: 846 Bytes
Versions: 2
Compression:
Stored size: 846 Bytes
Contents
# NOTE: This is example # To use in your app, need more rescue_from handler in app require 'active_support' require 'active_record-errors-localizer' using ActiveRecord::Errors::Localize # Common error handler in all controllers # class UsersController < ApplicationController # include ErrorHandler # end module ErrorHandler extend ActiveSupport::Concern included do # ... other rescue_from rescue_from ActiveRecord::RecordNotFound do |e| render json: { error_message: e.i18n_message }, status: :not_found end rescue_from ActiveRecord::RecordNotSaved do |e| render json: { error_message: e.i18n_message }, status: :bad_request end rescue_from ActiveRecord::RecordNotDestroyed do |e| render json: { error_message: e.i18n_message }, status: :bad_request end # ... other rescue_from end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_record-errors-localize-0.1.1 | examples/error_handler.rb |
active_record-errors-localize-0.1.0 | examples/error_handler.rb |