kaminari

rails 3,Kaminari pagination for an simple Array

只愿长相守 提交于 2019-12-17 17:54:29
问题 For paginating a common array I got this solution, @arr_name = Kaminari.paginate_array(@arr_name).page(params[:page]).per(PER_PAGE_RECORDS) PER_PAGE_RECORDS is a variable with value as per needed for pagination. Any better Ideas?? Also to have an ajax call for using pagination one can use this, In your view, give id to your div tab div id="paginate" and inside it <%= paginate @arr_name, :remote => true %> And in js response file put, $('#paginate').html('<%= escape_javascript(paginate(@arr

How do I paginate a hash of arrays using the Kaminari (or will_paginate) gem

允我心安 提交于 2019-12-14 04:27:06
问题 I've managed to find a workaround to this now. The index action now has an "order" clause before the call to page and the meals are then sorted and grouped by date. The hackey bit next: @total_pages and @pages are used in the view to provide pagination links as the built-in helper for this does not work with the Hash of arrays as returned by @meals. It works (kind of) but it is hackey. Moving the view stuff into a helper would definitely help clean it up, which is my next step. def index

Rails: undefined method 'paginates_per'

别来无恙 提交于 2019-12-13 14:02:06
问题 I'm installing a gem called Carrier https://github.com/stanislaw/carrier/blob/master/Gemfile into a Rails 3.2.1 app. It uses Kaminari and when I did bundle install after adding gem "carrier" to my Gemfile, it showed that I was using kaminari Using kaminari (0.13.0) However, when I tried to rake db:migrate, I got this error rake aborted undefined method `paginates_per' for Carrier::Chain(Table doesn't exist):Class Can anyone suggest a fix for this? I've copied the gemfile from the Carrier gem

Rails heroku help kaminari view error

对着背影说爱祢 提交于 2019-12-13 06:51:44
问题 I get an error in my heroku log because of kaminari . The pagnation does not either work on my local pc. Here is my log: I@PC /c/rails/myapp (master) $ heroku logs 2011-05-04T12:24:15-07:00 heroku[web.1]: State changed from created to starting 2011-05-04T12:24:15-07:00 heroku[slugc]: Slug compilation finished 2011-05-04T19:24:16+00:00 app[web.1]: >> Stopping ... 2011-05-04T19:24:24+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious) 2011-05-04T19:24:24+00:00 app[web.1]: >>

Wrong url in paginate (kaminari) for search with %

自古美人都是妖i 提交于 2019-12-13 03:56:34
问题 I have paginate (kaminari) on search page, and if i search somthing with % like "50% discount" i get page http://some.domain.com/50%25+discount where paginate has wrong urls (without escaping %) like: http://some.domain.com/50%+discount?page=2 Do i do somthing wrong? Or it's bug in gem? Thank you 回答1: % is a special character in urls isn't it? Your going to need your search method to sanitize the query before it gets passed to the url. I believe you can use the methods for the String class

Pagination not working only with a certain query

若如初见. 提交于 2019-12-13 03:01:51
问题 I am using Kaminari gem to paginate using ajax i have three paginations on the same page @all_questions = Question.where.not(id: current_user.question_ids).page(params[:unanswered]).per(1) @wrong = Tracker.where("user_id = ? AND correct = ?", current_user, false).page(params[:wrong_answers]).per(1) @answered = Tracker.where("user_id = ? AND answered = ?", current_user, true).page(params[:all_answered]).per(1) while the last two of the above instance variables correctly work. The first one

Kaminari with AJAX, unable to paginate

自作多情 提交于 2019-12-12 03:34:14
问题 I've followed the AJAX Kaminari example here: https://github.com/amatsuda/kaminari_example/tree/ajax I've successfully generated the partial and table. However, pressing the pages in the pagination does not update my table. In fact, upon pressing, the queries are the exact same data. I found a similar problem, however the solution remains unanswered: kaminari ajax pagination not updating the paginate I can verify that I am using the #paginator element. Some things I did do differently were

Spree infinite scroll not working

若如初见. 提交于 2019-12-12 03:26:20
问题 I have followed stackoverflow spree infinite scroll but still my infinite scroll is not working I am posting required files please help as I am new to spree platform assets/javascripts/spree/frontend/xyz.coffee jQuery -> if $('.pagination').length $(window).scroll -> url = $('.pagination .next').attr('href') if url && $(window).scrollTop() > $(document).height() - $(window).height() - $('#footer').height() $('.pagination').text("Fetching more products...") $.getScript(url) $(window).scroll()

Render an array in a view in ruby on rails

微笑、不失礼 提交于 2019-12-12 03:05:38
问题 At the controller end, I have an array @bookmarks = Bookmark.where('user_id = ? && note is NULL',current_user.id).order('created_at DESC').page(params[:page_2]).per(4) Then at the View I have this render tag through which I want to render @bookmarks <%= render @bookmarks %> Then there is page for _bookmark which will display @bookmarks bookmark.title bookmark.created_at But this process is giving me error of no partial. (I try to implement kaminari via Ajax) 回答1: using the render method like

Kaminari.paginate_array ArgumentError (wrong number of arguments (2 for 1)

断了今生、忘了曾经 提交于 2019-12-11 12:03:43
问题 I am using a rails application with the kaminari gem and I have a common array that I am trying to page using the paginate_array method but I am getting a ArgumentError (wrong number of arguments (2 for 1) exception. Here is the code: def index page = params[:page] || 1 items = ClientReports.search(params[:search], sort_column, sort_direction) @clients = Kaminari.paginate_array(items, total_count: items.count).page(page) respond_with(@clients) end The line: Kaminari.paginate_array(items,