Created
December 21, 2013 00:20
-
-
Save brunoandradd/8063685 to your computer and use it in GitHub Desktop.
Protected Show
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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