Created
April 11, 2020 23:42
-
-
Save swrobel/871e35876b308a0ade689b1f8f113342 to your computer and use it in GitHub Desktop.
Generic finders for a rails base controller
This file contains 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
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