Michael Schuerig
2005-Aug-19 03:00 UTC
Scaffold generator: How to make it use the correct table name?
The scaffold generator doesn''t play nicely with me. I have a model class Vertrag (contract) for which I''d like to generate a corresponding controller class named VertragController. When I simply run $ script/generate scaffold Vertrag Vertrag the generator tries to access a table named "vertrags" which doesn''t exist; the correct name would be "vertraege". Incidentally, that''s the table name set in the Vertrag model class. The generator doesn''t use this, though, as it doesn''t know about the class. Instead it fakes an "empty" class of the same name. So, let''s make the generator know about the real class $ ruby -r config/environment.rb -r app/model/vertrag.rb \ script/generate scaffold Vertrag Vertrag Duh, outsmarted again: The name ''Vertrag'' is reserved by Ruby on Rails. Please choose an alternative and run this generator again. It''s the depended-upon model generator who complains when it''s asked to create a class that already exists. The :collision => :skip doesn''t help in this case, apparently. Apart from moving to an english-speaking country, is there anything I can do about all this? Michael -- Michael Schuerig I am the sum total of the parts mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org I control directly. http://www.schuerig.de/michael/ --Daniel C. Dennett, Elbow Room