i'm trying to make an advanced search in my rails app but i'm having some problems with empty params
class Product< ActiveRecord::Base searchkick
when i fill the search and size fields everyting works, but if i leave size field blank nothing show up in the results...
probably i'm doing something stupid
i made it work with a bunch of IFs:
def index
if params[:search].present?
if params[:size].present?
@products = Product.search params[:search], where: {size: params[:size]}
else
@products = Product.search params[:search]
end
else
if params[:size].present?
@products = Product.search "*", where: {size: params[:size]}
else
@products = Product.search "*"
end
end
but probably thats not the best approuch, having in mind that i will search in at least 5 other fields...
Search, Size, Brand, Color, Store.state, Price, Rating etc...
sorry for my english, i hope you guys understand my question and get able to help me..