Scaffold question

there are some things on a scaffold that i would like to use without the
whole thing. is it better to generate one and then cut it down to only
what you’ll use?

are all of the things in a scaffold available to just build by hand? for
instance, i have a scaffold for my users. in the list action, it has
@user_pages, so that you can put @user_pages.current.next or something
like that - is that something i can do with any of my model
automatically just by having @model_pages in the action?

Scaffolding is nothing magical: it’s just a time-saving way to generate
a bunch of files and boilerplate code you typically need when initially
building an application or adding major new sections to one.

You’ll most likely find yourself generating a scaffold for one or two
central models (maybe your main public model and controller and your
main admin controller), and from there you’ll create a bunch of extra
views by hand or copy-and-paste and often just do a “generate model”
when you create secondary tables and classes. “generate scaffold” will
generally just come into play when a new table you create needs its own
admin interface.

You can create all these files by hand, but matching filenames to the
CamelCase class names is a hassle when you’re doing more than one at a
time, and if you want all the scaffold actions and views it’ll usually
be easier to generate and edit than to copy and paste and try to get the
class name right in a dozen places. When you need a new model, helper
and CRUD controller and views all at once, a generate is usually going
to make more sense than doing it by hand. On the other hand, sometimes
you’ll just need one new file, like a model for a non-database class,
and you’ll create it by hand.

Work the way it makes sense to you, and over time you’ll get a feel for
when you want to generate a full scaffold, just generate a model or
controller, or create a file by hand.

Josh K. wrote:

there are some things on a scaffold that i would like to use without the
whole thing. is it better to generate one and then cut it down to only
what you’ll use?

are all of the things in a scaffold available to just build by hand? for
instance, i have a scaffold for my users. in the list action, it has
@user_pages, so that you can put @user_pages.current.next or something
like that - is that something i can do with any of my model
automatically just by having @model_pages in the action?

so is being able to call @mymodel_pages part of the rails syntax for any
model?

i tried searching for it, but it’s kind of hard since it starts with the
model name and that’s usually always different.

Josh K. wrote:

so is being able to call @mymodel_pages part of the rails syntax for any
model?

i tried searching for it, but it’s kind of hard since it starts with the
model name and that’s usually always different.

Not quite. Look in the controller code for list. There will be a line
like this:

@user_pages, @users = paginate :users, :per_page => 10

I may be mistaken here, but with the exception of @params core Rails
contains no instance variables which you won’t find defined someone in
the scaffold code.

-Adam