Basic Doubts


#1

I’ve just started a project and I’ve been having some basic doubts.
Firstly,
I created my db schema using a db modeling tool. Then I generated the
tables
according to that model. After I created the schema.rb. The database.yml
is
ok and also the first migration. My doubt is: when I run
script/generate
scaffold Post
for example, it creates my view without any field, even
if
all the tables are created and my migration before scaffolding has the
correct definition to the Post table. Instead of using the current
migration, the scaffold command creates a new one. Is there any way to
run
scaffold and do not create a new migration without fields? I wouldn’t
like
to write down the schema of each table every time I wanted to use
scaffold.

Second doubt: Can I run script/generate model Post without create a
new
migration or write down the fields definition? I’d like to use what is
on
the database and on the current migration (the whole schema)

Thanks in advance


Rodrigo F.
Web D.
SCJP


#2

On Apr 29, 2009, at 8:25 AM, Rodrigo F. wrote:

wouldn’t like to write down the schema of each table every time I
wanted to use scaffold.

You probably want to either:

  1. Move beyond using the scaffold and roll your own code once you
    understand what’s going on
  2. START with the scaffold as a place to begin and let it create the
    initial migration, model, controller, etc.

Second doubt: Can I run script/generate model Post without create a
new migration or write down the fields definition? I’d like to use
what is on the database and on the current migration (the whole
schema)

You can run just:
script/generate model
to get help on the generator (or just script/generate to see what
generators are available)

You want the --skip-migration option. You can also just create your
own model file (and test or spec file to go along with it).

Thanks in advance


Rodrigo F.
Web D.
SCJP

You’re Welcome,
-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid