kaminari

How to use Kaminari pagination gem with Sinatra and Mongoid?

邮差的信 提交于 2019-12-08 06:40:31
问题 Presumably, not a whole lot of configuration is required - docs. The gem doesn't seem to work. Relevant code: Gemfile: source 'https://rubygems.org' ruby '2.2.4' gem 'sinatra' gem 'thin' gem 'slim' gem 'json' gem 'mongoid' gem 'kaminari' web.rb: require 'sinatra' require 'json' require 'mongoid' require 'kaminari' # Mongoid class class Affiliate include Mongoid::Document field :name, type: String end # MongoDB connection info and whatnot Mongoid.load!('mongoid.yml', :development) get '

Rails Pagination with Kaminari with has_many :through Relationship

喜你入骨 提交于 2019-12-08 05:44:02
问题 I have three relevant models. A User which has_many :photos and belongs_to :dorm , a Dorm which has_many :users and has_many :photos, :through => :users , and a Photo class which belongs_to :users and belongs_to :dorm . I want to paginate all the photos that are in a dorm with kaminari. I have it in my Gemfile and ran the bundle command. In my dorms_controller: @dorm=Dorm.find(params[:id]) @photos=@dorm.photos.page(params[:page]).per(3) and in my Dorm show view (actually in a partial, _index

Kaminari undefined method `page' with Rails 4.2

你离开我真会死。 提交于 2019-12-08 03:59:33
I am using Kaminari 0.16.3 with Rails 4.2.0 . Not sure what is going wrong, I have pasted code run by me in console, which proves kaminari gem is loaded but page method is undefined on ActiveRecord model. abhishek@abhishek ~/my_app (master●●)$ rails c [ruby-2.1.5p273] Loading development environment (Rails 4.2.0) irb(main):001:0> Kaminari => Kaminari irb(main):002:0> User.page NoMethodError: undefined method `page' for User (call 'User.connection' to establish a connection):Class Please note: I am intentionally calling page without any arguments to reproduce the issue. Due to an issue with

Kaminari undefined method `page' with Rails 4.2

两盒软妹~` 提交于 2019-12-08 03:53:09
问题 I am using Kaminari 0.16.3 with Rails 4.2.0 . Not sure what is going wrong, I have pasted code run by me in console, which proves kaminari gem is loaded but page method is undefined on ActiveRecord model. abhishek@abhishek ~/my_app (master●●)$ rails c [ruby-2.1.5p273] Loading development environment (Rails 4.2.0) irb(main):001:0> Kaminari => Kaminari irb(main):002:0> User.page NoMethodError: undefined method `page' for User (call 'User.connection' to establish a connection):Class Please note:

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

半世苍凉 提交于 2019-12-08 03:45:27
问题 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

show all results on one page (gem kaminari)

陌路散爱 提交于 2019-12-07 02:57:46
问题 I have data and they be cut on some pages (10 results per page). code in controller: @messages = Message.order('id DESC').page params[:page] How I can show all results on one page if I want? It similar as 'see all' on page navigate. 回答1: You can put a very high limit in the per_page option if you still want the paginate helpers to work in your view. @messages = Message.order('id DESC').page params[:page] if params[:all] @messages = @messages.per_page(Message.count) # you can also hardcod' it

Rails 5.0.0.beta1 - Generating an URL from non sanitized request parameters is insecure

与世无争的帅哥 提交于 2019-12-06 17:13:21
问题 We are upgrading from Rails 4.2.5 to 5.0.0.beta1 When testing we expected to see index views rendered with paginated links as before. But we now get an ArgumentError error page, for example: ArgumentError in Transactions#index /app/views/kaminari/_paginator.html.erb where line #10 raised: <%= paginator.render do -%> Generating an URL from non sanitized request parameters is insecure! Application Trace | Framework Trace | Full Trace app/views/kaminari/_paginator.html.erb:10:in block in _app

Problem with nested resources with Kaminari pagination gem

自作多情 提交于 2019-12-06 15:21:40
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://localhost/paintings?artist_id=foobar&page=2 It's supposed to be: http://localhost/artists/foobar/paintings

find page for given record using kaminari

偶尔善良 提交于 2019-12-06 06:49:59
问题 Ruby on Rails 3 project. After updating a record we return to the index of all records (not a view of the updated record). The index is paged with Kaminari. How do we return to the page of the index that contains the updated record? 回答1: There is a similar question and answer for Java JPA/Hibernate Finding out the page containing a given record using JPA (Hibernate) that shows the sql needed to get the offset of the record in the index view. Something like SELECT COUNT(*) FROM Model r WHERE r

Kaminari and Capybara conflict

戏子无情 提交于 2019-12-06 05:13:33
问题 I seem to have some sort of conflict between the page method of capybara and the page method of Kaminari. That's what I guessed, anyway, here is the error : Failure/Error: before { sign_in_as user } ActionView::Template::Error: wrong number of arguments (1 for 0) # ./app/models/feed.rb:9:in `microposts' [Rest of the backtrace] The code sample : class Feed def microposts(opts = { urgent: false }) urgent = opts[:urgent] p Microposts.where(id: 1).page # <Capybara::Session> p Microposts.where(id: