Module: PennyWise::Integration::Rails

Defined in:
lib/penny_wise/integrations/rails.rb,
lib/penny_wise/integrations/rails/railtie.rb

Defined Under Namespace

Classes: Railtie

Instance Method Summary collapse

Instance Method Details

#error_renderer(code) ⇒ Object



10
11
12
13
14
# File 'lib/penny_wise/integrations/rails.rb', line 10

def error_renderer(code)
  return render PennyWise.configuration.error_template,
                status: code,
                layout: PennyWise.configuration.error_layout
end

#failure_renderer(code) ⇒ Object



16
17
18
# File 'lib/penny_wise/integrations/rails.rb', line 16

def failure_renderer(code)
  render status: code, text: PennyWise.configuration.failure_message
end

#routing_errorObject

Raises:

  • (ActionController::RoutingError)


21
22
23
24
25
26
# File 'lib/penny_wise/integrations/rails.rb', line 21

def routing_error
  # Raise traditional Rack-level Rails RoutingError at Application-level instead,
  # so it `rescue_from` in PennyWise's error handler can catch it instead of Rack's.
  # Works in conjunction with a catchall route pointed at this method.
  raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
end