Skip to content

Instantly share code, notes, and snippets.

@swrobel

swrobel/finders.rb

Created Apr 11, 2020
Embed
What would you like to do?
Generic finders for a rails base controller
def model
@model ||= controller_name.classify.constantize
end
def record
@record ||= records.find(params[:id])
end
def records
@records ||= policy_scope(model) # Requires Pundit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment