Skip to content

Instantly share code, notes, and snippets.

@adyrcz
Last active August 29, 2015 14:03
Show Gist options
  • Save adyrcz/d5db81ade1fefb769189 to your computer and use it in GitHub Desktop.
Save adyrcz/d5db81ade1fefb769189 to your computer and use it in GitHub Desktop.
Auditcontroller.rb
class AuditsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :correct_user, only: [:edit, :update, :destroy]
before_action :set_audit, only: [:show, :edit, :update, :destroy]
.
.
.
.
.
.
def correct_user
@audit = current_user.audit.find_by(id: params[:id])
redirect_to audits_path, notice: "Not authorized to edit this Test" if @audit.nil?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment