Sha256: bc45e87a953a5495af3bd6afd2412aefc0f00c158b3858c8652d7ac18801d1b3
Contents?: true
Size: 795 Bytes
Versions: 17
Compression:
Stored size: 795 Bytes
Contents
# frozen_string_literal: true class ErrorHandlingWithChainsController < ApplicationController # Example where the query chain is resolved # in the view (during render 'show') def fetch_in_view @records = DummyRecord .rescue(LHC::Error, ->(error) { handle_error(error) }) .where(color: 'blue') render 'show' render_error if @error end # Example where the query chain is resolved # before the view is rendered def fetch_in_controller @records = DummyRecord .rescue(LHC::Error, ->(error) { handle_error(error) }) .where(color: 'blue').fetch render 'show' render_error if @error end private def handle_error(error) @error = error nil end def render_error self.response_body = nil render 'error' end end
Version data entries
17 entries across 17 versions & 1 rubygems