Skip to content

Instantly share code, notes, and snippets.

@WaKeMaTTa
Created April 7, 2017 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WaKeMaTTa/0717d354fa3d428cec6b0be4a8b7664b to your computer and use it in GitHub Desktop.
Save WaKeMaTTa/0717d354fa3d428cec6b0be4a8b7664b to your computer and use it in GitHub Desktop.
Use alias_method for better readability
# app/policies/application_policy.rb
class ApplicationPolicy
attr_reader :user, :record
def initialize(current_user, record)
@user = user
@record = record
end
end
# app/policies/post_policy.rb
class PostPolicy < ApplicationPolicy
alias_method :post, :record
def update?
post.user == user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment