sinefunc / pagination Goto Github PK
View Code? Open in Web Editor NEWTrying to make the pagination world a better place
Home Page: http://sinefunc.com/labs
License: MIT License
Trying to make the pagination world a better place
Home Page: http://sinefunc.com/labs
License: MIT License
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
I see that your code is streamlined for:
Sinatra
Ohm
HAML
Any plans on SLIM Documentation/Support?
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.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.