Just started using Ransack and i'm loving it. But desperate to know how to start with a blank index, with no results? forcing the user to use the search form. Here what the controller looks like so far.
meals_controller.rb
def index
@search = Meal.search(params[:q])
@meals = @search.result
end
edit -
Some how this worked and i'm not sure how
meals_controller.rb
class MealsController < ApplicationController
before_filter :set_search
def index
if params[:q].blank?
@q = Meal.none.search
else
@q = Meal.search params[:q]
end
@meals = @q.result
end
def set_search
@search=Meal.search(params[:q])
end
end
ransack
(@q
) and the predecessormetasearch
(@search
) – Sidecar