Help with paginate, collection.size error?!


#1

hi, i am trying to pass the paginate_collection function this.

@pages, @viewObj = paginate_collection Mcategory.find(params[:id],
:include => {:scategories => :howtos}), :page => @params[:page]

however, the problem seems that this format cant be read into the
collection.size method.

NoMethodError (undefined method size' for #<Mcategory:0x22b0c84>): /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1792:inmethod_missing’

but when i try with a simple collection call of find(:all), it works
fine. so i am guessing it doesnt like my include statement.


#2

i am using this…

def paginate_collection(collection, options = {})
logger.debug "----~CALLING PAGIONATE!!!== "
default_options = {:per_page => 5, :page => 1}
options = default_options.merge options

pages = Paginator.new self, collection.size, options[:per_page],
options[:page]
#pages = Paginator.new self, 50, options[:per_page], options[:page]

first = pages.current.offset
last = [first + options[:per_page], collection.size].min
#last = [first + options[:per_page], 50].min

slice = collection[first...last]
return [pages, slice]

end