# Easy scaffold question(s)

**URL:** <https://www.ruby-forum.com/t/easy-scaffold-question-s/55794>\
**Category:** Rails\
**Created:** [March 23, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794 "2006-03-23T21:38:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 23, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/1 "2006-03-23T21:38:56Z")

</div>

I’m doing very well with the Hibbs Rolling on Rails tutorial. I have an  
easy question for my personal notes. I’m coming up with a simple  
framework  
of steps for creating a basic database. It includes the following  
maxims to  
make original app creation easy:

app\_name = MySQL database name  
SQL\_tablename = model\_name  
model\_name = controller-name

Is this going to work for getting the simple structure set up? This  
naming  
convention seems easy to me and should work. I’d like feedback on this  
before I “make it real” for my process notes.

Second question. with this convention I’m running scaffold to get  
things up  
and running for testing purposes. I’ll replace the scaffold items one  
at a  
time until things work as expected.

when I run scaffold I’ll type “scaffold :recipes” for example. Am I  
scaffolding the MySQL table when I do this or am I scaffolding the ruby  
model\_name?

Thanks in advance!

* * *

Joshua Burke  
Web M.  
Heartland AEA 11

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 23, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/2 "2006-03-23T22:29:11Z")

</div>

I’m not sure but I think if you use the script/scaffolding it will  
create the model and the controller at the same time… (I’m using  
RadRails and it works like that)

You can also use the rails --pretend command to see if you are doing the  
right thing.

Cheers

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 23, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/3 "2006-03-23T22:42:21Z")

</div>

When it scaffolds though, what is it scaffolding? Is it pulling the  
MySQL tablename or the ruby model\_name?

Joshua

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 23, 2006, 10:50pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/4 "2006-03-23T22:50:05Z")

</div>

Can I go with an example? I’ll show you what convention I follow.

Application name “Cookbook”.

You’d usually set up two databases on your development box:

cookbook\_test  
cookbook\_development

One model:

ruby script/generate Recipe # generates Recipe model

The table would be called: recipes (always plural)

The controller can be called: “recipe” or “recipes”. Most people  
prefer plural, i.e. “recipes”

To answer your second question: I never use scaffold, but I checked  
[http://api.rubyonrails.com/](http://api.rubyonrails.com/) and you should always use the singular  
name of your model, e.g.

scaffold :recipe

Rob

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 23, 2006, 11:17pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/5 "2006-03-23T23:17:38Z")

</div>

When you enter the scaffold call into your controller (as is done in  
the cookbook tutorial), you are using dynamic scaffolding that works  
at run time. This will track changes in your tables.

If, instead, you run the scaffold command from the command line, this  
will physically generate the scaffold code into real files and  
represents the definition of your table at the time you run the  
command. While this is less flexible, it does let you actually see the  
code (and modify it).

Curt

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 24, 2006, 4:17pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/6 "2006-03-24T16:17:36Z")

</div>

Thanks for hanging in there with the new guy. One final question about  
scaffolding. What I’ve been doing is placing the scaffold :model\_name  
in  
the controller (as per Hibbs tutorial part 1) and then, when I get  
everything just the way I want it I generate a scaffold command as you  
have  
indicated below (and as per Hibbs tutorial part 2). This allows me to  
edit  
the scaffold code and generally allows me an easy transition between the  
dynamic scaffold and replacing and controlling each element of the  
scaffold  
individually.

This seems to work well and so far it has allowed me to get into  
customization much more quickly than defining and controlling each def  
individually.

So, I’m actually using both methods to great advantage. I " dynamically  
scaffold" until I’ve got things in the order I want them in general and  
then  
generate a scaffold to create editable code. The generated scaffold  
pulls  
over (for the most part) everything as it was in the dynamic scaffold  
and  
saves this poor n00b a lot of headache.

The question is, is this going to bite me in the butt later on? I can’t  
see  
a disadvantage but I thought I’d ask the forum. I’m trying to set up a  
series of “ruby habits” that will be guideposts when creating apps from  
scratch.

Joshua

---

<div class="post-metadata">

**Author:** ![jdw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dbc845/32.png) [@jdw](https://www.ruby-forum.com/u/jdw)\
**Post date:** [March 24, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/easy-scaffold-question-s/55794/7 "2006-03-24T17:39:01Z")

</div>

On 3/24/06, Web M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> customization much more quickly than defining and controlling each def  
> series of “ruby habits” that will be guideposts when creating apps from  
> scratch.

That’s precisely the way the I do it.

Curt
