Found it, and let me just say “ew”.
As folks may know, the scaffold generator does not play nicely with
set_table_name now, if you’re using it. Even if you plan to use a table
of an unexpected name, which you can do, it will still look for
emailtemplates or whatever during generation time. The solution is easy
- just create an empty table with the expected name.
Nope, and that’s my problem. The _form was looking at that empty table,
and of course seeing nothing. Funny, too, since “list” executes at
runtime and properly responds to set_table_name, so it would see the
columns that exist in the desired table, but _form was empty because it
had nothing to iterate over.
Solution - you need a properly named and properly setup table to exist
before running the scaffold generator.
I see that my app/view/email/_form.rhtml file contains only this:
<%= error_messages_for ‘emailtemplate’ %>
which is probably a big part of the problem. But the scaffold command
did not give any hint of a problem:
[[email protected] admin]# script/generate scaffold emailtemplate Email
Any ideas? What data, specific to my app, does the scaffold generator
even look at? I though the _form file just generically said “Get the
columns in the database and display a field for each of them associated
with the column name”.
I’ve generated the standard scaffolding half a dozen times on play
databases on my own machine, but now I’m trying it for real against the
team’s development database (postgres) and I see to have ended up in
some sort of read-only mode. “list” will show my existing records and
“show” will drill down, as expected, but “New” or “Edit” just show a
blank screen with a New/Edit button - no empty (or populated) form
fields to fill in.
I really have no idea how that might have happened. I did all the usual
script/generate scaffold emailtemplate thing, created table
emailtemplates in my database with an id field, and so on.
Anybody seen that one before? the only other thing I can think that’s
changed is this is the first time I’m using rails 1.x, previous attempts
were prior to the official 1.0 launch.