#2 open
Schwab

pagination in exception logger

Reported by Schwab | September 19th, 2007 @ 04:45 PM

To make this compatible with rails 2, a new approach to pagination is needed. the classic_pagination plugin would probably work without changes. to use will_paginate I just had to make LoggedException the receiver for the call to paginate, and specify :page => params[:page] || 1, and remove the :logged_exceptions and :per_page parameters in the controller, and replace the pagination divs in the view.

Comments and changes to this ticket

  • steve odom

    steve odom December 28th, 2007 @ 12:23 PM

    Following up on what Schwab said above for using will_paginate, here's what I did:

    I replaced line 34 in the logged_exceptions controller with:

    @exceptions = LoggedException.paginate :order => 'created_at desc', :page => params[:page], :per_page => 30, 
            :conditions => conditions.empty? ? nil : parameters.unshift(conditions * ' and ')
    
    

    And in the _exceptions.rhtml partial I replaced the 2 pagination divs at the top and bottom that look like this:

    <% if @exception_pages.page_count > 1 %>
    <div class="pages pages-bottom">
    Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :action => :index } %></strong>
    </div>
    <% end %>
    

    With:

    <div class="pages pages-bottom">
    Pages: <strong><%= will_paginate @exceptions -%></strong>
    </div>
    
  • Sudara

    Sudara January 23rd, 2008 @ 09:19 AM

    Just want to add that those changes make it rails 2 friendly and working.

    Only other thing to note is that it might help a few folks out to add the following route to the readme:

    map.logged_exceptions 'logged_exceptions/:action/:id',    :controller => 'logged_exceptions'
    
  • Sudara

    Sudara January 23rd, 2008 @ 10:32 AM

    whups, one more thing:

    the readme could also note that for most new apps (rails 2), you'll need to also include protect_from_forgery.

  • Rick

    Rick January 27th, 2008 @ 02:22 PM

    • State changed from “new” to “open”

    Hey, I guess I don't check this often enough. Chris Wanstrath made an enhancement to the plugin that uses will_paginate. I plan on cherry picking that commit.

    Sudara: where are you adding #protect_from_forgery? I'm not keen on adding it to the plugin if it'll break Rails 1.2 users.

  • Sudara

    Sudara January 27th, 2008 @ 05:19 PM

    ahoy.

    Sorry for that. Maybe I'm on crack, but I needed it hanging out in production.rb - Not a biggie, but worth mentioning in that nice readme of yours.

    Thanks

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages