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.
13 lines
350 B
Ruby
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
|