Git Product home page Git Product logo

Comments (14)

sanks64 avatar sanks64 commented on June 12, 2024

The workaround that I came up with:

# all_sites_grid.rb
class AllSitesGrid < BaseGrid
  scope do
    []
  end
end

# sites_controller.rb
grid = AllSitesGrid.new do
  Site.dataset.paginate(1, 25).to_a
end

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

Can you open the console and run Site.dataset.paginate(1, 25)? If it generates an exception for you, there is nothing datagrid can do about it and you are using sequel incorrectly. You may search for support in sequel forums.

Anyway, your grid imitation code looks incorrect. It should be:

grid = AllSitesGrid.new do |scope|
  scope.paginate(1, 25)
end

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

It works in the console:

irb(main):001:0> Site.dataset.paginate(1, 25)
=> #<Sequel::Postgres::Dataset: "SELECT * FROM \"sites\" LIMIT 25 OFFSET 0">

Not sure what you mean by grid imitation, but this is the error with your suggestion:

NoMethodError: undefined method `paginate' for Site:Class

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

Try the following:

# all_sites_grid.rb
class AllSitesGrid < BaseGrid
  scope do
    Site.dataset
  end
end

# sites_controller.rb
grid = AllSitesGrid.new do |s|
  s.paginate(1, 25)
end

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

The same error even on master:

Sequel::Error: You cannot paginate a dataset that already has a limit

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

Try the following in console:

AllSitesGrid.new.scope.paginate(1,25)
AllSitesGrid.new.assets.paginate(1,25)

What is the result?

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024
irb(main):001:0> AllSitesGrid.new.scope.paginate(1, 25)
=> #<Sequel::Postgres::Dataset: "SELECT * FROM \"sites\" LIMIT 25 OFFSET 0">
irb(main):002:0> AllSitesGrid.new.assets.paginate(1, 25)
=> #<Sequel::Postgres::Dataset: "SELECT * FROM \"sites\" LIMIT 25 OFFSET 0">

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

Try the following too:

AllSitesGrid.new{|s| s.paginate(1,25)}.assets.to_a

Also, let me know, which specific line is showing up in the backtrace with the error.

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

Sorry, but can't you try it? It should be easy to reproduce.

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

I did. It is not reproducing.

class PaginationTest

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

The test fails though.

Also, doing scope.limit(10) results in the same error.

from datagrid.

bogdan avatar bogdan commented on June 12, 2024

I have no idea how limit appears in your code. You need to provide a full controller action, view, grid and model source code.

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

See #312.

from datagrid.

sanks64 avatar sanks64 commented on June 12, 2024

Thanks!

from datagrid.

Related Issues (20)

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.