-
-
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
Is there a workaround for a model named "Page"? #1709
Comments
Uh, that's indeed a bug. I have put together some code that might help. Mind trying out branch master...pablobm:fix-page and tell us how it went? Thank you. |
The paging links for unsorted results now work. Clicking a table column header to sort records, however, generates the following error message:
I'm ok renaming my model if you don't think this can be remedied in an elegant manner. I'm also here to help if you'd like to continue investigating. In any regard, thanks! |
Thank you again for that diagnosis. I have pushed a new change to that branch. Would you have time to try it out? The bug should definitely be fixed, and I don't expect it to be a particularly difficult fix. |
You've squashed another part it -- well done. The only problem I see is the paging when the records are sorted. I don't encounter an exception but the behavior isn't correct. The paging links don't retain the sorting. I didn't look at the code but I imagine the Example:
Note: The |
Uh, that's strange. I'm not able to reproduce. There's something odd about the URLs you show though: the query param should be called |
You're right, it's my setup. Sorry for the confusion. Thanks for all your help. 👏 |
Actually, I'm reopening because the bug does still exist. I should create a PR from my branch above, which should fix it properly. |
Using the param :page for top-level pagination (ie: index pages as opposed to has_many lists in show pages) conflicts with paginating resources whose type happens to be "Page". Instead of a unit test, a feature spec is used as the pagination code is all over the place making this quite tricky. Ideally, we should move all the pagination code into a single module that can be tested in isolation. This in turn is not easy, as Kaminari doesn't make it easy. A new feature spec called pagination_spec.rb, bringing over other pre-existing pagination examples, to help organise things, and also to take advantage of the helper method expect_to_appear_in_order in the new example. Fixes #1709
How to solve this issue? |
I updated the administrate version to 0.15 and fix this error. |
If anyone else is having an issue with this, see the following for a potential solution: #2359 (comment) |
I didn't find any documentation about reserved names for the administrate gem. Is there a workaround for a model named
Page
? When I create a standard dashboard (rails g administrate:dashboard Page
), I encounter a variety of errors. For example, when trying to access the pagination links on theindex
view.The issue relates to the paging/sorting information being stored under the same param key as the resource.
Rails: 6.0.3.2
administrate: 0.13.0
The text was updated successfully, but these errors were encountered: