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. Duane -- Posted via http://www.ruby-forum.com/.
I see that my app/view/email/_form.rhtml file contains only this: <%= error_messages_for ''emailtemplate'' %> <!--[form:emailtemplate]--> <!--[eoform:emailtemplate]--> which is probably a big part of the problem. But the scaffold command did not give any hint of a problem: [root@trump admin]# script/generate scaffold emailtemplate Email exists app/controllers/ exists app/helpers/ exists app/views/email exists test/functional/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ skip app/models/emailtemplate.rb identical test/unit/emailtemplate_test.rb identical test/fixtures/emailtemplates.yml create app/views/email/_form.rhtml create app/views/email/list.rhtml create app/views/email/show.rhtml create app/views/email/new.rhtml create app/views/email/edit.rhtml create app/controllers/email_controller.rb create test/functional/email_controller_test.rb create app/helpers/email_helper.rb create app/views/layouts/email.rhtml identical public/stylesheets/scaffold.css 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". Duane wrote:> 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. > > Duane-- Posted via http://www.ruby-forum.com/.
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. Duane wrote:> I see that my app/view/email/_form.rhtml file contains only this: > > <%= error_messages_for ''emailtemplate'' %> > > <!--[form:emailtemplate]--> > <!--[eoform:emailtemplate]--> > > > which is probably a big part of the problem. But the scaffold command > did not give any hint of a problem: > > [root@trump admin]# script/generate scaffold emailtemplate Email > exists app/controllers/ > exists app/helpers/ > exists app/views/email > exists test/functional/ > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > skip app/models/emailtemplate.rb > identical test/unit/emailtemplate_test.rb > identical test/fixtures/emailtemplates.yml > create app/views/email/_form.rhtml > create app/views/email/list.rhtml > create app/views/email/show.rhtml > create app/views/email/new.rhtml > create app/views/email/edit.rhtml > create app/controllers/email_controller.rb > create test/functional/email_controller_test.rb > create app/helpers/email_helper.rb > create app/views/layouts/email.rhtml > identical public/stylesheets/scaffold.css > > > 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". > > Duane wrote: >> 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. >> >> Duane-- Posted via http://www.ruby-forum.com/.
Seemingly Similar Threads
- has_many, through, want to store email in mysql
- (newbie) Missing Template Error using Rolling With Rails Tutorials
- How do you create a controller & view to create a list of objects?
- Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
- observe_field question