I'm trying to setup Rails Administrate - https://github.com/thoughtbot/administrate.
Following the docs:
gem "administrate"
in theGemfile
rails generate administrate:install
- "Restart your server, and visit http://localhost:3000/admin to see your new dashboard in action."
From the Rails log, when visiting localhost:3000/admin
I see the following SQL query is executed:
Order Load (0.7ms) SELECT "orders".* FROM "orders" LIMIT $1 OFFSET $2 [["LIMIT", 25], ["OFFSET", 475]]
Why is the OFFSET
put on 475?
But more importantly, how do set it to 0 or remove it at all?
UPDATE:
- I'm using
will_paginate
too (possible conflict here?) - My Kaminari settings in:
config/initializers/kaminari_config.rb
:
Kaminari.configure do |config|
config.default_per_page = 25
config.max_per_page = nil
config.window = 4
config.outer_window = 0
config.left = 0
config.right = 0
config.page_method_name = :per
config.param_name = :page
config.max_pages = nil
config.params_on_first_page = false
end
SOLUTION
will_paginate
was interfering with kaminari
I created an initializer for will_paginate
:
# config/initializers/will_paginate.rb
if defined?(WillPaginate)
module WillPaginate
module ActiveRecord
module RelationMethods
def per(value = nil) per_page(value) end
def total_count() count end
def first_page?() self == first end
def last_page?() self == last end
end
end
module CollectionMethods
alias_method :num_pages, :total_pages
end
end
end
Now it works!