Skip to content

Instantly share code, notes, and snippets.

@starwels
Created January 20, 2020 13:46
Show Gist options
  • Save starwels/3e190237ba77d62285ead5ae61fc97fd to your computer and use it in GitHub Desktop.
Save starwels/3e190237ba77d62285ead5ae61fc97fd to your computer and use it in GitHub Desktop.
class BarController < ApplicationController
before_action :find_bar
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def show
end
private
def find_bar
Bar.find(params[:id])
end
def record_not_found
redirect_to bar_path, error: "Sorry, no bar found."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment