Why do I get an empty class when I run ruby script/generate scaffold?

I've been trying to figure this out since yesterday afternoon with no
success. I've tried to run ruby with oracle, 11, 10, and as of today
10g XE. The problem is obviously not on the oracle side because I can
query the database successfully using the command-line ruby exec
command.

But after I created an a simple ruby application with a simple
database table called emails that contains only one column called
email, running the generate scaffold command leaves me with an empty
class in email.rb:

class Email < ActiveRecord::Base
end

Isn't it supposed to populate the class with the database column
information?

The generate command completed successfully with no errors. I'm
totally lost at this point. Any pointers would be greatly appreciated.

The model's not supposed to populate with anything. The connections
are made in ActiveRecord behind the scenes. However, if you created a
scaffold, there should be some new files in the app/views/emails
directory if you had any columns in your table.

Still confused. Shouldn't the database migration .rb file under db/
migrate contain something that looks like my column names? I don't see
any files that contains any of my column names.

It sound like you somehow created the table first then tried to use
script/generate scaffold

This isn't the way it works. If you did say:

script/generate scaffold email body:text recipient:string

then it would generate a model, controller, views, AND a migration
file which would create a table called emails with three columns: id
(the primary key), body, and recipient.

script/generate scafold does not READ the database to get a table definition.

Sounds like you are missing rake db:migrate ?

Your migration files are located at PROJECT/db/migrate/00*.rb

This link explains my confusion. I almost gave up because I couldn't
get any of the basic tutorials going. http://wiki.rubyonrails.com/rails/pages/ScaffoldGenerator

The first sentence says "Rails 2.0.0+ breaks chapter 1 of every
existing quality rails tutorial because of scaffolding." Sigh ... it
makes me not so hopeful about learning this new platform. This seems
to be the general problem with any open source platform. Bad or lack
of quality documentation. It's too easy to get stuck, and too hard to
get out of being stuck.

I don't think it's the case of bad or lack of documentation, it's just
a new version that isn't full covered yet.

You can use the tutorials on the rails 1.2.x if you create your
application with: rails _1.2.6_, for example.

Then you can follow the 1.2.x tutorials to learn rails and after that
migrate to 2.0. That's the path I recommend.

[]'s
Marcos

Well. All's good. It's finally working. I did learn a lot through this
digging process. It's definitely not as easy as a lot of people say
though.

I completely agree with you. Half of the tutorials don't work with the
latest release and th changes are quite significant without barealy
any compatibility. It is taking forever to find out what is in the
present release. So much for the 'agile' platform.

I completely agree with you. Half of the tutorials don't work with the
latest release and th changes are quite significant without barealy
any compatibility. It is taking forever to find out what is in the
present release. So much for the 'agile' platform.

tutorials have been hit disproportionately hard, because they tend to lean on things that were extracted (scaffolding).
My rails 1.2 apps required very little changes (basically just grabbing the plugins for the extracted features).

Fred

I agree. It's not at all the fault of the framework that the freebie
tutorials have failed to keep up. With respect to the tutorials...
you get what you paid for. If you're willing to invest in your Rails
education, I'd recommend "The Rails Way" (Fernandez, Addison-Wesley
Professional series). It's as comprehensive a text as you'll find AND
it was written with Rails 2.x in view. Also, railscasts is a great
(still free!) source for tutorials. You'll probably want to
concentrate on the later editions since they will cover Rails 2.x as
well.