will-paginate

Overriding a module method from a gem in Rails.

I've got a gem (will_paginate) that's broken on my version of Oracle. The default paginate_by_sql method in the WillPaginate module is inserting an extra 'AS' into a query and causing it to fail. The code itself is easily fixed, but i'm not sure of the best way to get rails to pick up my change. I don't want to change the code in the ...

Paginate through a randomized list of blog posts using will_paginate

I want to give users the ability to page through my blog posts in random order. I can't implement it like this: @posts = Post.paginate :page => params[:page], :order => 'RANDOM()' since the :order parameter is called with every query, and therefore I risk repeating blog posts. What's the best way to do this? ...

Item's page and will_paginate

I have some photos that are split on successive pages through will_paginate plugin. When you open a photo and then return to all photos using a link, you always return to the first page (e.g. the photo is displayed on page 5, you open the photo, click a link to show all photos and expect that you are on page 5 again, but you are on page ...

Help interpret will_paginate docs?

Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults to 1 if false or nil :per_page — defaults to CurrentModel.per_page (which is 30 if not overridden) :total_entries — use only if you manually count total entries :count — additional options that are passed on to count :finder — name of th...

Using will_paginate with multiple models (Rails)

Pretty sure that I'm missing something really simple here: I'm trying to display a series of pages that contain instances of two different models - Profiles and Groups. I need them ordering by their name attribute. I could select all of the instances for each model, then sort and paginate them, but this feels sloppy and inefficient. I'...

Rails: Showing 10 or 20 or 50 results per page with will_paginate how to?

Hi community, me again... I need show 10 or 20 or 50 results number of results per page with a select options in my list of posts using will_paginate plugin Can you help me please? Thanks! ...

Overriding Rails mislav-will_paginate plugin

I'm working with the Rails mislav-will_paginate plugin to paginate my records. I want to produce the following output, regardless of whether there were multiple pages: X - Y of Z 1 - 100 of 1826 will_paginate in WillPaginate::ViewHelpers returns nil if there was only one page of records. I want to override this in the cleanest possibl...

will_paginate undefined method `total_pages'

What am I missing here? I am using the haml_scaffold generator and the pages work fine with will_paginate. When I start tinkering I end up with this 'total_pages' error and I'm not sure what I am doing that is causing it. Anyone have any insight? I'm using mislav-will_paginate 2.3.11. mike@jauntyjackalope:~/project$ script/console Load...

Using will_paginate without :total_entries to improve a lengthy query

I have a current implementation of will_paginate that uses the paginate_by_sql method to build the collection to be paginated. We have a custom query for total_entries that's very complicated and puts a large load on our DB. Therefore we would like to cut total_entries from the pagination altogether. In other words, instead of the t...

will paginate miscounting oddness with named scopes

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 =...

How to use will_paginate with a nested resource in Rails?

I'm new to Rails, and I'm having major trouble getting will_paginate to work with a nested resource. I have two models, Statement and Invoice. will_paginate is working on Statement, but I can't get it to work on Invoice. I know I'd doing something silly, but I can't figure it out and the examples I've found on google won't work for me. ...

Using searchlogic with will_paginate

EDIT Looks like I figured it out - I had to call paginate after the call to all from Searchlogic. I'm trying to use both of these tools to enable users to search contacts and return a paginated list (or the entire paginated list if they don't enter any search criteria). However I'm unsure of the proper way to chain them together, and w...

How do I install will_paginate in ruby?

I'm trying to install will paginate. I installed the gem, as detailed on the github page. The gem installed OK, but when I tried a line like @user = User.paginate I just got an error message about the paginate method not existing. So, I uninstalled the gem and tried using the plugin method: script/plugin install svn://errtheblog.co...

many_to_many, sti and will paginate

Hi, i have following code class Category < ActiveRecord::Base has_many :categorizations has_many :posts, :through => :categorizations end class Post < ActiveRecord::Base has_many :categorizations has_many :categories, :through => :categorizations end class Categorization < ActiveRecord::Base belongs_to :post belongs_to :ca...

will_paginate works on local box, gives "undefined method to_i" on server but both point to the same database

We just ran into this problem the other day all of a sudden. Our Rails app is using will_paginate, and I have it defined as follows in my controller: # contacts_controller.rb def index # ... @search = @current_user.contacts.search(params[:search]) @contacts = @search.all.paginate({:page => params[:page], :per_page => 20}) end B...

Rails will_paginate routing caching duplicate pages

I use the will_paginate plug-in. In oder to generate routes that I can cache ( /posts/index/2 instead of /posts?page=2) I added the following to my routes.rb: map.connect '/posts/index/1', :controller => 'redirect', :url => '/posts/' map.connect 'posts/index/:page', :controller => 'posts', :action => 'index', ...

Rails how to expire a directory?

How to expire a directory in Rails? I have a blog where /posts/ lists all the posts. Controller posts, action index. Pretty standard stuff. Posts are paginated in groups of 10 using will_paginate. The pages are being cached like this: /posts/ /posts/index/2 /posts/index/3 /posts/index/4 ... /posts/index/134 /posts/index/135 ... e...

Will_Paginate::Collection missing the total_entries property

I am creating a Will_Paginate::Collection object using the following code @paginatedResults = WillPaginate::Collection.new(1, 5) @paginatedResults.replace @results[@paginatedResults.offset, @paginatedResults.per_page] but when I try to render the pagination using <%= will_paginate @paginatedResults...

How can I change the link format in will_paginate for page_cache in Ruby on Rails?

I want to use page_cache with will_paginate. There are good information on this page below. http://railsenvy.com/2007/2/28/rails-caching-tutorial#pagination http://railslab.newrelic.com/2009/02/05/episode-5-advanced-page-caching I wrote routes.rb looks like: map.connect '/products/page/:page', :controller => 'products', :action => 'i...

Rails - Passing a collection to the layout for will_paginate?

I have my <%= will_paginate %> code block in the layout of my application. I'd like to pass this block different collections depending on what controller/action I'm in. How can I do this? ...