Sha256: 4ea408959fd89009a840596a0d50a18b0c0a2ef7c16b45171b6722fa834a2ff7
Contents?: true
Size: 795 Bytes
Versions: 12
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(DHC::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(DHC::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
12 entries across 12 versions & 1 rubygems