Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. def index
  2. if @category.present?
  3. @classifieds = @category.nested_classifieds
  4. nested_categories = []
  5. @category.nested_categories.each do |f|
  6. nested_categories << f.id
  7. end
  8.  
  9. @search = Sunspot.search(Classified) do
  10. paginate(:page => params[:page] || 1, :per_page => 10)
  11. order_by(:created_at , :desc)
  12. fulltext params[:search]
  13. with(:categoryid,nested_categories)
  14. with(:price).less_than_or_equal_to(params[:prcmax].to_i) if params[:prcmax].present?
  15. with(:price).greater_than_or_equal_to(params[:prcmin].to_i) if params[:prcmin].present?
  16. active_model = with(:model ,params[:model]) if params[:model].present?
  17. active_make = with(:make , params[:make]) if params[:make].present?
  18. active_make_country = with(:make_country , params[:make_country]) if params[:make_country].present?
  19. active_condition = with(:condition,params[:condition]) if params[:condition].present?
  20. active_category = with(:cat,params[:cat]) if params[:cat].present?
  21. active_subcategory = with(:treecat,params[:treecat]) if params[:treecat].present?
  22.  
  23. facet :price
  24.  
  25.  
  26. facet(:model)
  27. #facet(:model , exclude: active_condition)
  28. facet(:make)
  29. facet(:make_country)
  30. facet(:condition)
  31. facet(:cat)
  32. facet(:treecat)
  33. end
  34. @classifieds = @search.results
  35. else
  36. #redirect_to '/'
  37. #@classified=@search.results
  38. search
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement