title: How to paginate elements of an array after sorting on it?
body: <p>I've got a controller method that sorts elements by a derived attribute.  I can print to the view as long as I don't attempt to paginate.  When I call <code>@foos = @foos.page params[:page]</code> I get the following error: <code>undefined method 'page' for #&lt;Array:...&gt;</code> </p>
  
  <p>Can anyone provide some guidance here?  Thanks. </p>
  
  <p>Here's the whole controller method:</p>
  
  <pre><code>def index_by_capacity
      if current_user.is_view_major?
        @foos = Foo.major_attr(:name)
      else
        @foos = Foo.order(:name)
      end
  
  
    @foos = @foos.sort_by! {|a| a.capacity_available.to_i }
    @total_foos = @foos.count
  
    @foos = @foos.page params[:page]
  
    respond_to do |format|
      format.html
      format.json { render json: @foos }
    end
  end
  </code></pre>