Ruby scaffolding

Soldato
Joined
18 Oct 2002
Posts
9,048
Location
London
I'm just trying out some things with RoR, and I want to change the number of results per page when using the scaffolding. This is what I have so far from a quick google, but I just get the normal 10 results.

Code:
class TvshowController < ApplicationController
  scaffold :tvshow

  def default_per_page
    50
  end
end

The ruby api seems to be down too
http://api.rubyonrails.org/
So if anyone has any ideas that'd be great!
 
Well the api seems to be back up.

1st question, have you actually generated the scaffold code? This is quite useful to do, as you can then hack around with what's going on behind the scenes.

What you want to be looking at is the list method, which determines what is done when you want a list of things.


E.g. If I want a list of rooms, 10 per page, I will have something like this:


Code:
class RoomsController < ApplicationController

  def index
    list
    render :action => 'list'
  end

  def list
    @room_pages, @rooms = paginate :rooms, :per_page => 10
  end

end

And strictly speaking this is a question about Rails, not Ruby. Ruby is a regular, interpreted programming language of it's own right.
 
Back
Top Bottom