Git Product home page Git Product logo

pagination's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pagination's Issues

Paginate items can't iterate

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

SLIM Support

I see that your code is streamlined for:

Sinatra
Ohm
HAML

Any plans on SLIM Documentation/Support?

Make easy to switch pagination adapters

Hello,

I'm using Pagination with my own custom ActiveRecordAdapter and also creating one for ThinkingSphinx.

The problem is that every time I need to switch adapters need to first set it with Pagination.adapter, then use Pagination.paginate and remember to switch it back

Will be great if the adapter could be passed over options as :adapter => :ActiveRecordAdapter or :adapter => :ThinkingSphinxAdapter

Thank you.

autoload is failing due wrong usage of attr in collection

Hello,

When trying to use Pagination standalone with Ohm, it mentions it cannot find OhmAdapter.

After trying to get it manually, saw this error:

Pagination::OhmAdapter
ArgumentError: wrong number of arguments (3 for 2)
        from C:/Users/Luis/.bundle/ruby/1.8/gems/pagination-0.3.1/lib/pagination/collection.rb

According to Ruby documentation:

http://apidock.com/ruby/Module/attr

attr should be used to set a default value in a instance variable.

I believe attr_reader is best suited for it?

Thank you.

Ohm Adapter do not contemplate lists for pagination

With Ohm 0.1.0.rc5 we found that Pagination.paginate do not work as expected (it results in 0 results always)

Since we use a list, not a set or sorted set, we thought that would be reason.

Indeed it was, as it assumes sort be part of the list, which is:

http://github.com/sinefunc/pagination/blob/master/lib/pagination/adapters/ohm.rb#L16

But it raises and ERR and by that, end in no result at all.

Since list respond to simple array behaviors, we monkey patched it to use [@start..(@start + @per_page - 1)] in results method.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.