will-paginate

How to Store and Paginate XML Data as a Rails Model

I have an XML feed I am pulling down and parsing in my Rails app. I started to implement it as a library in lib/ but it seemed more logical to me to treat it as a model. For convenience I am treating it as an ActiveRecord model. A requirement is that it is compatible with mislav's will_paginate plugin, although that is where I am havi...

De facto approach to sorting with will_paginate

I'm using the will_paginate gem to display a collection in a paginated fashion. Now I'd like to have sorting functionality on the columns of the list in the view. I've added my own custom mechanism for establishing this, but it left me wondering if there isn't a standard way of doing this, leveraging the simplicity and elegance of will_p...

Paginate ordering doesn't work when using find_all_by_completed(false)

In my project model def incomplete @clients = current_user.clients.find_all_by_completed(false).paginate (:page => params[:page], :per_page => 10, :order => 'started_on DESC') end For some reason it doesn't order started_on descending. However ordering works in another method def all @clients = current_user.clients.paginate(:...

Ajax error after pagination

I'm using ruby on rails 2.3.2, and I've got a list with checkboxes. So I created a remote_form_for to handle multiple submit buttons. Those operations work great, and so the pagination. The problem raises when I both submit the form and then try to paginate. I get the following error instead of displaying next page, as expected. try { E...

reverse page numbers with will_paginate

Is there any simple way to reverse page numeration with will_paginate? I want for the top page (last time-wise) to be #1, and the last (earliest) to be #N. The reason for that is page contents shouldn't change with time, which is good for SEO. ...

Returning from viewing a record to that specific record in a paginated data set

I have a simple Rails app and for example purposes we'll say I have a customer model. If I have 1000 customers and I'm on page 6 when I click to view the details on a specific customer, what would be the best method so when I click a "Return to list" link, that it takes me back to page 6 and possibly even does a scroll to an anchor that...

Filtering a Table in Rails

I am working with will_paginate to create a sortable and searchable table. I have got everything to work correctly with the exception of the search box (filter). Right now when I select a different query (other than "title") and search for something, it only searches for title querys. Can anyone help point out where I am going wrong? Th...

Sort by ranking algorithm using will-paginate

I'm creating a digg-like site using Ruby on Rails that ranks the item (based on this algorithm). I'm using the will-paginate gem list the items in pages. The problem is, will-paginate only allows me to insert ':order =>' based on the table data. I would like to make will-paginate to sort by a number which is calculated using a function ...

Why did mislav-will_paginate start adding so much garbage to urls between rails 2.3.2 and 2.3.5?

I've used will_paginate in a number of projects now, but when I moved one of them to Rails 2.3.5, clicking on any of the pagination links (page number, next, prev, etc.,) went from getting nice URLs like this: http://foo.com/user/1/date/2005_01_31/phone/555-6161 to this: http://foo.com/?options[]=user&options[]=date&options[]...

rails will_paginate and sorting with page caching

Hi! I have a website where in the category 'show' action a list of products is shown. I successfully paginate with the will_paginate plugin and made this work with page caching by configuring my routes like Sean Behan does: http://seanbehan.com/ruby-on-rails/how-to-use-pretty-urls-with-rails-will_paginate-plugin/. But I would love to ...

will_paginate -> How to change the default url?

will_paginate plugin aways generates the pagination to the current url appending the page parameter. Is there a way to change this? I need it to paginate to another controller/action plus some arguments. ...

Rails will_paginate custom route

How can I use will_paginate with a custom route? I have the following in my routes: map.connect 'human-readable/:name', :controller => :tags, :action => 'show' but will_paginate uses url_for as far as I can tell, but I want to use 'human-readable' instead of url_for, but how? Edit When I click the paging link generated by will_pagi...

Will_paginate stuck on page 2

For some reason my will_paginate collection is stuck on page 2. I have the usual links the view helper provides except every page after page one links to http://localhost:3000/ceo/gr_messages?page=2 I have tried to add the :order option with no luck. I have also ensured that the request is a get as mentioned on this page: http://wiki.git...

Rails paginate existing array of ActiveRecord results

Hello, I generally use will_paginate for the pagination in my app, but have hit a stumbler on my search feature. I'm using Thinking Sphinx for doing my full-text search, which returns results paginated. The problem I'm having is that after I've received the results from Thinking Sphinx, I need to merge them with some other results and r...

Using will_paginate with AJAX live search with jQuery in Rails

I am using will_paginate to successfully page through records. I am also using AJAX live search via jQuery to update my results div. No problem so far. The issue I have is when trying to paginate through those live search results. I simply get "Page is loading..." with no div update. Am I missing something fundamental? I believe I may ne...

Ruby on Rails activerecord find average in one sql and Will_Paginate

Hi all I have the following model association: a student model and has_many scores. I need to make a list showing their names and average, min, max scores. So far I am using student.scores.average(:score) on each student, and I realise that it is doing one sql per student. How can I make the list with one joined sql? Also how would I...

is it possible to combine will_paginate with find_by_sql?

In my rails application I want to use will_paginate plugin to paginate on my query. Is that possible? I tried doing something like this but it didn't work: @users = User.find_by_sql(" SELECT u.id, u.first_name, u.last_name, CASE WHEN r.user_accepted =1 AND (r.friend_accepted =0 || r.friend_accepted IS NULL) ....

Rails has_many conditions

c = "(f.profile_id = #{self.id} OR f.friend_id = #{self.id})" c += AND + "(CASE WHEN f.profile_id=#{self.id} THEN f.friend_id ELSE f.profile_id END = p.id)" c += AND + "(CASE WHEN f.profile_id=#{self.id} THEN f.profile_rejected ELSE f.friend_rejected END = 1)" c += AND + "(p.banned = 0)" I need this to be used in a has_...

Mocha no longer can be loaded after installing will_paginate 3.0pre

So I came about the strangest rails bug. I have been starting a new rails3 app, and just installed will_paginate 3.0pre. Unfortunately the rails 3.0.0.beta2 update made some of will_paginate 3.0pre code deprecated. I did a quick fix. In gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb: ... #railtie_name :will_paginate #Old co...

Rails (pagination and tags)

Hey, I stumbled upon a problem of how to make work together acts_as_taggable (on steroids) and will_paginate gems. What I found on this problem is this: http://www.mckinneystation.com/2007/08/20/pagination-with-acts_as_taggable_on_steroids-acts_as_ferret-and-will_paginate/ But it's dated of 2007, may be there's something more recent? A...