Skip to content

Instantly share code, notes, and snippets.

@brunoandradd
Created December 21, 2013 00:20
Show Gist options
  • Save brunoandradd/8063685 to your computer and use it in GitHub Desktop.
Save brunoandradd/8063685 to your computer and use it in GitHub Desktop.
Protected Show
class PacientesController < ApplicationController
before_action :protected_show, only: [:show]
def show
@paciente = Paciente.find(params[:id])
end
private
def protected_show
unless clinica_logada.pacientes.where(id: params[:id]).any?
render file: "public/404.html", status: 404, layout: false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment