kaminari

Multiple pagination with kaminari via Ajax

房东的猫 提交于 2019-12-03 09:02:44
问题 I want to apply multiple pagination with Kaminari via Ajax now here is my code for controller def user_note @user = current_user @notes = Bookmark.where('user_id = ? && note is not NULL',current_user.id).order('created_at DESC').page(params[:page_1]).per(4) @bookmarks = Bookmark.where('user_id = ? && note is NULL',current_user.id).order('created_at DESC').page(params[:page_2]).per(4) respond_to do |format| format.html format.xml{ render :xml => @user} end end now for views i have two partials

Unwanted form parameters being appended to pagination links

大城市里の小女人 提交于 2019-12-03 06:07:42
I have a page which is used for searching through listings by submitting data using the supplied forms. The form parameters are submitted via ajax (post request), a new record is created in the searches table and then the listings are displayed (dynamically, on the same page the form is submitted from) via the show action for this record. The results have pagination links provided by kaminari like so: <%= paginate matches, :params => {:controller => 'searches', # I have to specify the id because my searches are stored in the database :action => 'show', :id => search.id}, :remote => true %>

Paginate Multiple Models in Kaminari

可紊 提交于 2019-12-02 19:04:39
I'm creating a search page that will do an application wide search on users, posts, and comments. I currently have: # POST /search def index query = params[:query] @users = User.search(query).page(params[:page]) @posts = Post.search(query).page(params[:page]) @comments = Comment.search(query).page(params[:page]) respond_to do |format| format.html end end However I'm really trying to get something where all the results are mixed together then paginated. What are some of the strategies for doing paginated search like this? Thanks! Before thinking about a solution, you need to first define

total_pages return in pagination with rails and kaminari

别来无恙 提交于 2019-12-02 04:09:10
i want a pagination in my page, im using ruby and kaminari to this. class ServicesController < ApplicationController def index /@services = Service.order(name: :asc)/ @organs = Admin::Organ.all @services = @services.order(created_at: :desc).paginate(page:params[:page], per_page: 3 ) end this code, my control try paginate pages 3 to 3. In views: <%= paginate @organ.services %> As i want call the services with relationship to each organ i insert que last code im my view. The result are: undefined method `total_pages' for #<Mongoid::Criteria:0x007f18a8b1f338> if you can help, grateful for the

Rails 3/Kaminari/JQuery - load more button: problem to display results (it loads the entire page layout and not only the partial layout)

我的未来我决定 提交于 2019-11-30 07:36:35
Begin with ajax and jquery combined with rails, I am trying to create a "load more" link in the bottom of my user index page. My user index page should display the 10 first users, then clicking the link it loads the next 10 users on the bottom of the user div, etc.. I use Kaminari for pagination. I started with the following code: User_controller.rb def index @users = User.page(params[:page]).per(10) end User/index.html.erb <div id="users"> <%= render :partial => @users %> </div> <%= link_to "Load more", "#", :class => "next" %> _user.html.erb <div id="box"> <%= link_to full_name(user), user %

rails 3,Kaminari pagination for an simple Array

梦想与她 提交于 2019-11-28 05:46:28
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_name, :remote => true).to_s) %>'); So your requests will be AJAX. Thanks. This is the only available

Paginating an Array in Ruby with will_paginate

我是研究僧i 提交于 2019-11-26 07:33:27
问题 I have an array @level1 which looks like this : [[3.0, 4, 2], [2.0, 48, 3], [2.1, 56, 4], ............] I want to apply pagination on this array such each page displays only a few rows at once. I tried this: @temp1 = @level1.paginate(:page => params[:page]) But it throws the following error: undefined method `paginate\' for [[3.0, 4, 2], [2.0, 48, 3], [2.1, 56, 4]]:Array How can I perform pagination on this using will_paginate? 回答1: Sure, you can use WillPaginate::Collection to construct