will-paginate

Rails will_paginate gem with angular.js to do pagination

允我心安 提交于 2019-12-08 05:40:17
问题 Context: I have a Rails backend serving as an API to an Angular.JS front-end application. Task: I want to retrieve all of the records of different species of "dinosaurs" from the Rails backend. Since there are over 500 records, I want to only get 30 species at a time. My current approach: I am using the will_paginate gem in my Rails index controller action for the dinosaurs_controller. I have it running like this. def index @dinosaurs = Dinosaur.paginate(:page => params[:page], :per_page =>

Rails will_paginate gem with angular.js to do pagination

我与影子孤独终老i 提交于 2019-12-07 08:47:28
Context: I have a Rails backend serving as an API to an Angular.JS front-end application. Task: I want to retrieve all of the records of different species of "dinosaurs" from the Rails backend. Since there are over 500 records, I want to only get 30 species at a time. My current approach: I am using the will_paginate gem in my Rails index controller action for the dinosaurs_controller. I have it running like this. def index @dinosaurs = Dinosaur.paginate(:page => params[:page], :per_page => 30) end In my Angular code: I have a module called DinoApp and am using ngresource to create an Entry

uninitialized constant ActionView::CompiledTemplates::BootstrapPagination

a 夏天 提交于 2019-12-07 01:07:26
问题 I have installed the will_paginate-bootstrap gem to use bootstrap style pagination. I have this in my view: <%= will_paginate @mylist, renderer: BootstrapPagination::Rails %> but it returns this error uninitialized constant ActionView::CompiledTemplates::BootstrapPagination 回答1: If you have successfully bundle all the gems then it should work like this. <%= will_paginate @mylist, :renderer => BootstrapPagination::Rails %> Please make sure you have restarted the server after installing the gem

Give custom messages in page_entries_info of will_paginate in rails

空扰寡人 提交于 2019-12-06 23:58:21
问题 I am new to rails. I want to display my custom message for page_entries_info. I have gone through following link but cannot understand much. Can anyone please explain in details. how-do-i-specify-custom-wording-in-a-will-paginate-view-helper 回答1: Another option is you can define your page_entries_info() method in your ApplicationHelper and use it as you normally would. This would give you more flexibility and can even be more cleaner and efficient if you know that you dont need to cover the

will_paginate helper undefined in sinatra with mongoid

空扰寡人 提交于 2019-12-06 16:48:25
I am using sinatra 1.4.3 and mongoid 3.1.4. I tried adding will_paginate gem from master branch for mongoid support so I added this to my gemfile: gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => 'master' In environment.rb I added: require 'will_paginate' require 'will_paginate/mongoid' And pagination method started working. I have still problem with will_paginate helper. In my views I get errors like: NoMethodError: undefined method `will_paginate' for #<Class:0x006ff5df8578b0> Am I missing something for helper to work under sinatra? I don't know if it's

Endless page with will_paginate not working with partial

故事扮演 提交于 2019-12-06 07:02:06
问题 I've been following the railscast on endless page and had previously done the same for will_paginate, but I'm getting errors however I try to implement it in my specific situation. The will_paginate gems works perfectly, as does the jQuery call to the dom as far as I can tell from reading the developer tools in Chrome. The issue is with what is being returned - rails doesn't like it. Here's some code: In videos.js.coffee : jQuery -> if $('.pagination').length $(window).scroll -> url = $('

Testing views with will_paginate Gem using Capybara/Rspec

无人久伴 提交于 2019-12-06 06:17:16
Doing Michael Hartl's Rails Tutorial, on chapter 10, section 5, exercise 2 . I am - very simply - trying to write tests to ensure that a pagination div appears on a couple pages using the will_paginate gem (this seems to be Hartl's preferred method of testing whether pagination works), but when I add the following code.. subject { page } . . . it { should have_selector('div.pagination') } ..it returns.. 1) UserPages profile page Failure/Error: it { should have_selector('div.pagination') } expected css "div.pagination" to return something This is especially odd because in this particular _spec

will paginate miscounting oddness with named scopes

戏子无情 提交于 2019-12-05 19:29:45
I recently broke up my query into 4 named scopes to make it easier to re-sort and will paginate which otherwise always worked fine now has problems calculating the number of pages. named_scope :loc, lambda { |id| { :conditions => ['location_id = ?', id ] } } named_scope :datem, lambda { |*args| { :joins => :scannables, :conditions => [ "scannables.bookdate BETWEEN ? and ?", (args[0].to_date || 3.days.from_now), (args[0].to_date+(args[1] || 3)) ], :group => 'scannables.hostel_id', :having => 'SUM(scannables.available) > ' + ((args[1] || 3).to_i-1).to_s } } named_scope :order_by_external_desc,

NoMethodError undefined method `link_to_function'

帅比萌擦擦* 提交于 2019-12-05 12:29:07
I added ActiveAdmin to my app, updated some gems and now I get a undefined method `link_to_function' when viewing users show page. I have the will_paginate gem and I added a initializer so there's no conflict. kaminari.rb: Kaminari.configure do |config| config.page_method_name = :per_page_kaminari end The error points to the line on from /app/helpers/will_paginate_helper.rb: @template.link_to_function(text.to_s.html_safe, ajax_call, attributes) Add a helper method and it will fix your problem. link_to_function_helper.rb: module LinkToFunctionHelper def link_to_function(name, *args, &block)

Give custom messages in page_entries_info of will_paginate in rails

北战南征 提交于 2019-12-05 05:44:17
I am new to rails. I want to display my custom message for page_entries_info. I have gone through following link but cannot understand much. Can anyone please explain in details. how-do-i-specify-custom-wording-in-a-will-paginate-view-helper Another option is you can define your page_entries_info() method in your ApplicationHelper and use it as you normally would. This would give you more flexibility and can even be more cleaner and efficient if you know that you dont need to cover the edge cases (as in my case). You can refer the original method definition here and see what all you need to