-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kaminari pagination conflict with installed gem #1838
Comments
Worry not: The error about |
Yes, I do not use Kaminari, but |
OK. I'm afraid this is a known bug that we need to look into, and see how we can incorporate pagination in a way that doesn't interfere with other people's gem choices. I did some surface research some time ago and it didn't look simple. We may need to try again. Of course, ideas, feedback, and contributions are welcome on this front. |
Announce the colours on the getting started page for starters ( ;-) ). The only thing that comes to mind is seperating out the views from the search/split logic, allowing dev to edit a directory of partials that respond to the pagination method with what the gem offers. possibly a sub-directory named that of the installed gem? Cheers! |
Let's leave this open. It's actually a bug, and we should address it at some point. Your suggestion does have merit. I'll bear it in mind when I try again. |
OK. I have updated the title to better reflect the issue, for readers's sake. |
I'd add to this. I am in the middle of trying to solve this same bug. We use Pagy and we implemented Administrate. AFTER being somewhat committed, and gotten some data in our system.. only now do we realize that we can't paginate. Had we known from the get-go that Kaminari to the exclusion of others was a hard requirement, we'd likely have gone a different way. |
We use pagy in our main app and Administrate still works fine with Kaminari for the admin dashboards. I can't remember if something was configured somewhere for this to work. Using Administrate 0.14.0. NB: we have separate application controllers for the main app ( |
It would be nice to be able to configure the pagination by overriding the Ex: module Administrate
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def index
authorize_resource(resource_class)
search_term = params[:search].to_s.strip
resources = filter_resources(scoped_resource, search_term: search_term)
resources = apply_collection_includes(resources)
resources = order.apply(resources)
- resources = resources.page(params[:_page]).per(records_per_page)
+ resources = paginate_resources(resources, params[:_page], record_per_page)
page = Administrate::Page::Collection.new(dashboard, order: order)
render locals: {
resources: resources,
search_term: search_term,
page: page,
show_search_bar: show_search_bar?,
}
end
# ...
+ protected
+
+ def paginate_resources(resources, record_page, record_per_page)
+ resources.page(record_page).per(record_per_page)
+ end
private
# ...
end
end class Admin::ApplicationController < Administrate::ApplicationController
def paginate_resource(scope)
# Custom pagination.
end
end |
Sure, you can assign me, I'll draft a PR. 😊 |
Awesome! 🙌🏻 |
Hi any good idea for has_many pagination? |
@jubilee2 - What do you want to do? Would overriding https://github.com/thoughtbot/administrate/blob/main/lib/administrate/field/has_many.rb#L59 help? |
finally i found this solution |
Getting started. After
rails generate administrate:install
I re-started the server and went straight tohttp://localhost:3000/admin
Now the stack trace, which follows, has one line (the second) which is bothersome:
administrate (0.14.0) app/controllers/administrate/application_controller.rb:12:in 'index'
there is no
administrate
directory in theapp/controllers
directory; the classes underAdmin::ApplicationController
are present in a directory calledadmin
which is consistent with what https://administrate-prototype.herokuapp.com/getting_started the getting started guide indicates.If I change that directory to 'administrate' (out of sheer curiosity) and restart the server, the error becomes:
returning the output of rake:routes and, as expected, the top line is
/admin/users(.:format)
gem 'administrate', '~> 0.14.0'
Stack trace:
The text was updated successfully, but these errors were encountered: