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
class ClientsController | |
include OrderingHelpers | |
def index | |
# order_by sanitation should work fine here, with sanitation to created_by if invalid | |
@clients = Clients.order(sanitized_ordering).where(user_id: current_user.id) | |
# trying to order_by sales.date for example will fail here even if it's valid if the current controller is not ClientController | |
@clients = Clients.joins(:sales).order(sanitized_ordering.where(user_id: current_user.id) | |
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
# Call scopes directly from your URL params: | |
# | |
# @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
# with their associated values. For example, "{ status: 'delayed' }" would call |