Files
nairobi/app/controllers/concerns/access_denied_handler.rb
Javi Martín 27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +02:00

13 lines
350 B
Ruby

module AccessDeniedHandler
extend ActiveSupport::Concern
included do
rescue_from CanCan::AccessDenied do |exception|
respond_to do |format|
format.html { redirect_to main_app.root_path, alert: exception.message }
format.json { render json: { error: exception.message }, status: :forbidden }
end
end
end
end