kaminari

Rails / Kaminari - How to order a paginated array?

守給你的承諾、 提交于 2019-12-11 09:16:16
问题 I'm having a problem ordering an array that I've successfully paginated with Kaminari. In my controller I have: @things = @friend_things + @user_things @results = Kaminari.paginate_array(@things).page(params[:page]).per(20) I want to have the final @results array ordered by :created_at , but have had no luck getting ordering to work with the generic array wrapper that Kaminari provides. Is there a way to set the order in the Kaminari wrapper? Otherwise what would be the best way? Thanks. 回答1:

how add tag model (ActsAsTaggableOn) in rails_admin?

倖福魔咒の 提交于 2019-12-11 07:53:50
问题 I install rails admin and include all model in active record in rails admin, first time, when install rails admin display me this error NoMethodError in RailsAdmin::MainController#index undefined method `per_page_kaminari' for #<ActiveRecord::Relation:0x00000006713e18> and fixed it by added this configure Kaminari.configure do |config| config.page_method_name = :per_page_kaminari end when install acts_as_taggable_on gem in project, rails admin did't add tag model in it ( i added field tags

Rails Spree Kaminari infinite scrolling for the products page

我的梦境 提交于 2019-12-10 19:49:31
问题 I've tried to use this tutorial Kaminari endless page and also watched Ryan Bates episode #114 Endless Page (revised) and tried to implement an infinite scrolling functionality to my online store. I don't know for sure how to apply the products rendering in my index.js.erb file because it's quite different implemented in the Spree. I've also forgot to mention that I'm quite new to the Spree platform. All I've been doing so far was changing these files: views/spree/products/index.html <%

Kaminari: undefined method `total_pages' for Array

一笑奈何 提交于 2019-12-10 15:26:23
问题 Using Rails & Kaminari gem, I am getting the below error when I render my view: undefined method `total_pages' for #Array:0x007faa486583e0 controller: def index @user = current_shop.users.new @users = current_shop.active_users ### This returns an array Kaminari.paginate_array(@users).page(params[:page]).per(10) end view: <tbody> <%= paginate @users %> <% @users.each do |user| %> <%= render 'user_table_row', :user=> user %> <% end %> </tbody> What am I doing wrong? 回答1: I think you have to

Kaminari generates string instead of html

若如初见. 提交于 2019-12-10 10:54:15
问题 There was question like this in november, but no anwers was given. Kaminari generates string instead of html in production And no feedback from author, lack of reputation does not give me the opportunity to ask question there, also my problem a little bit different too. I'm using Rails 4.2.4, Kaminari 0.16.3 and slim as my template language. The pagination navigation is generated correctly, but = paginate @articles generates ALMOST a string instead of html. So it's escape tags and show them

How to set different page size for the first page in Kaminari?

只谈情不闲聊 提交于 2019-12-10 09:25:03
问题 I have a number of objects I would like to paginate using Kaminari. However, on the first page I would also like to show a notification allowing the viewer to create his own object, reducing the number of objects that can be displayed on that page. However, the indicated number of pages should also take into account that this first page contains less elements. Let's say the objects are the letters a through z. The first page should only 4 display letters: {a,b,c,d} , while all other pages

Kaminari & Rails pagination - undefined method `current_page'

試著忘記壹切 提交于 2019-12-09 14:00:49
问题 I searched and searched, but nothing solved my problem. Here's my controller: def show @topic = Topic.find(params[:id]) @topic.posts = @topic.posts.page(params[:page]).per(2) # 2 for debugging end That functions just fine, because the topic view is reduced to two posts. However, when I add this to show.html.erb: <%= paginate @topic.posts %> I'm given this error: undefined method `current_page' for #<ActiveRecord::Relation:0x69041c9b2d58> 回答1: Try with: def show @topic = Topic.find(params[:id]

Paginate Multiple Models in Kaminari

◇◆丶佛笑我妖孽 提交于 2019-12-09 04:10:20
问题 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

undefined method page for #<Array:0xc347540> kaminari “page” error. rails_admin

回眸只為那壹抹淺笑 提交于 2019-12-08 20:57:33
i am using rails_admin. when i go to certain resource. by typin url localhost:3000/admin/rule than it give me this error. code is: scope = Rule.all scope.page(1).per(2) . above code is writtten in rails_admin gem.in a file named mongoid.rb placed in adaptors folder. complete log is: NoMethodError (undefined method `page' for #<Array:0xcea7408>): mongoid (2.4.8) lib/mongoid/criteria.rb:385:in `method_missing' /home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/kaminari-809105ad782a/lib/kaminari/models/mongoid_extension.rb:11:in `page' /home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler

Problem with nested resources with Kaminari pagination gem

谁说胖子不能爱 提交于 2019-12-08 08:39:30
问题 Can't seem to get Kaminari to work properly with nested resources. Here is a description of my problem. Wondering if anybody was able to tackle this issue. My routes look like: resources :artists do resources :paintings end In my view, I have: <%= paginate @paintings, :params => { :controller => 'paintings', :action => 'index' } %> The initial / base url looks like this: http://localhost/artists/foobar/paintings But clicking on a kaminari paginate link, renders the url like this: http:/