I have following code:
module DataMapper
module Resource
@@page_size = 25
attr_accessor :current_page
attr_accessor :next_page
attr_accessor :prev_page
def first_page?
@prev_page
end
def last_page?
@next_page
end
def self.paginate(page)
if(page && page.to_i > 0)
@current_page = page.to_i - 1
else
@current_page = 0
end
entites = self.all(:offset => @current_page * @@page_size, :limit => @@page_size + 1)
if @current_page > 0
@prev_page = @current_page
end
if entites.size == @@page_size + 1
entites.pop
@next_page = (@current_page || 1) + 2
end
entites
end
end
end
Then I have call of #paginate:
@photos = Photo.paginate(params[:page])
And getting following error:
application error
NoMethodError at /dashboard/photos/
undefined method `paginate' for Photo:Class
In Active record this concept works fine for me... I'am using JRuby for notice. What I'am doing wrong?