pagination icon indicating copy to clipboard operation
pagination copied to clipboard

Paginate items can't iterate

Open psoldier opened this issue 11 years ago • 0 comments

Hello, I'm using Sinatra and Ohm and have the following problem

My Model:

module Dscd
  class Process <  Ohm::Model
    include Ohm::DataTypes
    include Ohm::Timestamps

    attribute :name
    attribute :enable, Type::Boolean

    index :name
    index :enable
  end
end

My route

get "/process" do
  @processes = paginate Dscd::Process.find(enable:true), per_page: 3, :sort_by=>  :created_at, :order=>"DESC"

  haml :'process/index'
end

when i try iterate on @processes

- @processes.each do |process| 
  ....

raises an exception (no implicit conversion of Fixnum into Array)

I debugged @processes and return me the following


>> @processes
=> #<Pagination::OhmAdapter:0xb5f51bfc @page=1, @per_page=3, @dataset=#<Ohm::Set:0xb5f51c4c @key="Dscd::Process:indices:enable:true", @namespace="Dscd::Process", @model=Dscd::Process>, @total=51, @sort_by=:created_at, @order="DESC", @start=0>


>> pagination @processes
=> "<nav class='pagination'>\n  <nav class='page-numbers'>\n    <span ...... 


 >> @processes.results
!! #<NoMethodError: undefined method `results' for #<Pagination::OhmAdapter:0xb5f51bfc>>

>> @processes.dataset
!! #<NoMethodError: undefined method `dataset' for #<Pagination::OhmAdapter:0xb5f51bfc> 

I don't understand why can't load collection in a @process

psoldier avatar Feb 03 '14 20:02 psoldier