Skip to content

kaminari divided by 0 error #68

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

Closed

Conversation

snop-snov
Copy link

When I try to use Hashie::Mash search query I get "divided by 0" error in kaminari paginate method

@karmi
Copy link
Contributor

karmi commented Apr 4, 2014

Unfortunately, we cannot just call ActiveSuport's deep_symbolize_keys here. The contract on the query object is that it simply provides a to_hash method and that's it.

I do agree, on the other hand, that the current behaviour is incorrect and surprising -- I'll look into documenting it better, and possibly using HashWithIndifferent internally.

In your case, just pass my_quer_object.to_hash.deep_symbolize_keys to the search method.

@karmi karmi added the waiting label Apr 4, 2014
@snop-snov
Copy link
Author

Yes, I hurried with deep_symbolize_keys including due to the fact that I used exactly my_quer_object.to_hash.deep_symbolize_keys to fix this error in my code.
and when I met it I was vary surprised =)
I hope this case will not be forgotten and will be handled correctly.
Thanks for your answer!

@karmi karmi added bug and removed waiting labels Apr 15, 2014
@karmi karmi closed this in e58ebfe Apr 16, 2014
@karmi
Copy link
Contributor

karmi commented Apr 16, 2014

Hi, I've changed the default value for the limit_value method, which now returns the default limit for the model or Kaminari.

This should prevenbt any ZeroDivisionError when you forget to chain the page() method to the search.


The original error for Google's sake:

ActionView::Template::Error (divided by 0):
    43: </table>
    44: 
    45: <div class="text-center">
    46:   <%= paginate @articles %>
    47: </div>
    48: 
    49: 
  app/views/articles/index.html.erb:46:in `_app_views_articles_index_html_erb__602758141288077419_70327030021060'
  app/controllers/articles_controller.rb:15:in `search'

@snop-snov snop-snov deleted the fix_search_request_definition branch April 24, 2014 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants