Last active
November 14, 2019 09:41
-
-
Save voising/f599a71fe446c628c3afc42a0cd9b8cc to your computer and use it in GitHub Desktop.
Marketplace - Search by rate & tags - Controller
This file contains hidden or 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
# frozen_string_literal: true | |
class ProductsController < ApplicationController | |
# GET /products | |
def index | |
๐๐ฎ๐ฌ๐ฌ ProductSerializer.new(filtered_products) | |
end | |
private | |
def filtered_products | |
query = Product.index | |
# RATE | |
query = query.filter_on_rate(params[:rate]) if params[:rate] | |
kinds = params.keys & Tag.kinds.keys | |
return query unless kinds.any? | |
# TAGS | |
query.filter_on_tags(kinds, params) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment