mislav/will_paginate — Issue #192: Scope with will_paginate
Author: Ditchou
Created: 2011-10-12 08:24:22+00:00
State: open

Hello,

I am usins scope in my controller to filter my models :

def filter
@hotels = Hotel.scoped

@hotels = @hotels.country(params[:country_id]) unless params[:country_id].blank?
@hotels = @hotels.city(params[:city_id]) unless params[:city_id].blank?
@hotels = @hotels.hoteltype(params[:hotel_type]) unless params[:hotel_type].blank?
@hotels = @hotels.theme(params[:hotel_theme]) unless params[:hotel_theme].blank?
@hotels = @hotels.prices(params[:hotel_prices]) unless params[:hotel_prices].blank?
@hotels = @hotels.services(params[:hotel_services]) unless params[:hotel_services].blank?

count = @hotels.count
@hotels.paginate :page => params[:page], :per_page => 12
end

But it didn't work, still has all @hotels in my @hotels variable.

What did i do wrong?

Thank you.