In the database I''m currently working in, a practice is followed of prefixing tables to keep them loosely categorized by application and purpose. The prefixes are usually three characters and an underscore(web_ for primary web interface, bil_ for billing, etc...). I really don''t care if the prefixes are there for the models, or even for the controller file names. It will really be a pain in the rear to go into every controller related file after using script/generate, and remove the prefix from the controller, tests, etc... so that the prefixes won''t show up, or be required in the web app. Is there a way to edit the templates for generation? Would editing the templates, or even changing the controller definitions by hand bring some hidden nastiness on my application? Woulds Rails not really care less if those controller names are different? Thanks, Steve
> In the database I''m currently working in, a practice is followed of > prefixing tables to keep them loosely categorized by application and > purpose. The prefixes are usually three characters and an underscore(web_ > for primary web interface, bil_ for billing, etc...). I really > don''t care if > the prefixes are there for the models, or even for the controller file > names. It will really be a pain in the rear to go into every controller > related file after using script/generate, and remove the prefix from the > controller, tests, etc... so that the prefixes won''t show up, or > be required > in the web app. > > Is there a way to edit the templates for generation? Would editing the > templates, or even changing the controller definitions by hand bring some > hidden nastiness on my application? Woulds Rails not really care less if > those controller names are different?Anyone have any thoughts on this? Steve
Steve- I don''t see why you''d need to have the controller''s prefixed at all (even when they are generated), unless you''re going to use them with their prefixes. Really what you want to do is explicitly map your models to a specific table in the database, instead of using the magically generated table names (based on class name) that Rails uses. To do this, just do something like this: class Project < ActiveRecord::Base set_table_name "web_project" end see: http://rails.rubyonrails.org/classes/ActiveRecord/Base.html#M000623 While this doesn''t help you update the templates so that this isn''t necessary, I can''t imagine that adding one line to your models would really take that long... or would it? Hope this helps, Ben On Apr 9, 2005 3:50 AM, Steve V <ruby-ChEX1j9zMF7JbC0vcoRRxNBPR1lH4CV8@public.gmane.org> wrote:> In the database I''m currently working in, a practice is followed of > prefixing tables to keep them loosely categorized by application and > purpose. The prefixes are usually three characters and an underscore(web_ > for primary web interface, bil_ for billing, etc...). I really don''t care if > the prefixes are there for the models, or even for the controller file > names. It will really be a pain in the rear to go into every controller > related file after using script/generate, and remove the prefix from the > controller, tests, etc... so that the prefixes won''t show up, or be required > in the web app. > > Is there a way to edit the templates for generation? Would editing the > templates, or even changing the controller definitions by hand bring some > hidden nastiness on my application? Woulds Rails not really care less if > those controller names are different? > > Thanks, > Steve > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> I don''t see why you''d need to have the controller''s prefixed at all > (even when they are generated), unless you''re going to use them with > their prefixes. Really what you want to do is explicitly map your > models to a specific table in the database, instead of using the > magically generated table names (based on class name) that Rails uses. > To do this, just do something like this: > > class Project < ActiveRecord::Base > set_table_name "web_project" > end > > see: http://rails.rubyonrails.org/classes/ActiveRecord/Base.html#M000623 > > While this doesn''t help you update the templates so that this isn''t > necessary, I can''t imagine that adding one line to your models would > really take that long... or would it?No, it wouldn''t take that long, and seems like it should be fine. I made the mistake of thinking that the model script queried the DB to check that the name specified existed as a table/view in the DB. Steve