That's probably 'cos you're setting the per_page parameter to nil in your controller.
And please remove this "fetch" param. it's useless, use only the per_page parameter for that. - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Sat, Jun 13, 2009 at 11:47 AM, Älphä Blüë<[email protected]> wrote: > > Okay, I kept the scope the same.. > > I actually liked both of your ideas and gives me a lot more > functionality with the method. This is what I went with: > > def self.list(search, page, per_page = 20, fetch = nil) > per_page = 120 if (fetch == "all") > compiled_this_week.paginate :conditions => ['name like ?', > "%#{search}%"], :order => 'rank', :per_page => per_page, :page => page > end > > I kept the "search" in because the name of the team(s) are being > returned via a clickable search button. So, it made sense to keep that > listed as search. I might change that though. > > The issue I have is when I bring up my default page, it lists (30 > teams). Now, I'm not sure why it's doing that. I have the per_page set > to 20. > > Here's an example: > > #-- Rushing Offenses Controller > > @rushing_offenses = RushingOffense.list(params[:search], params[:page], > params[:per_page], params[:fetch]) > > #-- Rushing Offenses Model > > named_scope :compiled_this_week, lambda { { :conditions => ['compiled_on >> ? and compiled_on < ?', Time.now.beginning_of_week, > Time.now.end_of_week] } } > > def self.list(search, page, per_page = 20, fetch = nil) > per_page = 120 if (fetch == "all") > compiled_this_week.paginate :conditions => ['name like ?', > "%#{search}%"], :order => 'rank', :per_page => per_page, :page => page > end > > #-- Rushing Offenses index.html > > <%= page_entries_info @rushing_offenses, :entry_name => 'Team' > %> > </div> > <%= link_to "Show All Teams", rushing_offenses_path(:fetch => > "all") %> > <%= will_paginate @rushing_offenses, :prev_label => '<<', > :next_label => '>>', :container => false %> > </div> > > =========================================== > > I'm not sure why it's pulling 30. I've been scratching my head at that > one. The Show All Teams shows 120 teams like it's supposed to. Each > page within the pagination shows a list of 30 teams when it's supposed > to show 20. > > > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

