Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.