**Note** I have not tried anything about my question, nor Googled anything about it yet, I was just wondering if this was possible, so if you wanna answer with lmgtfy, rtfm, or anything like that, please get it out of the way immediately. I have a simple address book app that I want to sort by last name, and put each letter on a different page. Can the Paginate Gem be customized this much, that is, to provide pagination by, let''s say record.last_name, and instead of page numbers, show A..Z instead?
Not that I know of, or have done... but I haven''t investigated the possibility. As an alternative, you could put a series of letter links at the top of your table (or down a side; images or CSS styled so they look nice) which filter your records by that letter, and leave the will_paginate gem as is to paginate the table body using all the filtered entries returned from the query. -- Posted via http://www.ruby-forum.com/.
This is for a glossary that I setup ... class Glossary def self.find_glossaries(options = {}) if options[:category].blank? paginate :per_page => options[:per_page], :page => options [:page], :conditions => ["term LIKE ?", options[:letter]+"%"], :order => "term" else end end end Then in the controller @letter = params[:letter].blank? ? @category.glossaries.collect.first.term.first.upcase : params[:letter] @glossaries = @category.glossaries.find_glossaries(:letter => @letter, :page => params[:page]) There is more to this but the the important one is the model find_glossaries And then this view helper: def letter_options(category=nil) if category.nil? @letter_options_list = Glossary.all.collect!{|c| c.term.first.upcase }.uniq.sort! else @letter_options_list = category.glossaries.collect!{|c| c.term.first.upcase }.uniq.sort! end end I hope this get you going...
Here''s how I implemented something similar. On the index page of my contacts, I list them alphabetically by default, paginated with 10 per page. At the top of this index page, I spit out the alphabet with each letter having it''s own link. Click any letter and I return all the contacts whose last name starts with that letter, paginated 10 per page of that letter. I also add some css styling to the letter they clicked to show which letter they''re on. Hope that helps. http://gist.github.com/175741