Is there a count_by_content alternative to the find_by_content action?

This is because I'm wanting to do the following in my pagination method:

def list
    # step 1: set the variables you'll need
    page = (params[:page] ||= 1).to_i
    items_per_page = 20
    offset = (page - 1) * items_per_page

    # step 2: instead of performing a find, just get a count
    item_count = Item.count_with_some_custom_method()

    # step 3: create a Paginator, the second argument has to be the
number of ALL items on all pages
    @item_pages = Paginator.new(self, item_count, items_per_page, page)

    # step 4: only find the requested subset of @items
    @items = Item.find_with_some_custom_method(items_per_page, offset)
end

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to