Skip to content

Instantly share code, notes, and snippets.

@diebels727
Created December 15, 2010 20:47
Show Gist options
  • Save diebels727/742584 to your computer and use it in GitHub Desktop.
Save diebels727/742584 to your computer and use it in GitHub Desktop.
#Trying to figure out why Report.all returns this:
irb(main):006:0> a = Report.all
=> [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ]
irb(main):008:0> a[0].class
=> Report
irb(main):009:0> a[0].inspect
=> nil
@diebels727
Copy link
Author

The problem (and solution) (reports_controller.rb)

  @reports = WillPaginate::Collection.create(current_page, per_page, @results.count) do |pager|

    #Problem was that current_page is a string -- so to_i makes pagination function after filtering...
    start = (current_page.to_i-1)*per_page

    pager.replace( @results[start, per_page] )

  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment