I''ve always wished that more apps shipped with the ability to specify a table prefix... that is, a string that would be automatically prepended to any table name in a database query. I''m currently hosting with a company that only allows one database, and it would be nice to be able to install/develop/use multiple Rails apps without worrying about table name collisions. Has anyone ever looked at this? Anyone ever done it? I haven''t dug down into the ActiveRecord API much, and I''m absolutely a Rails newbie, but I can''t imagine it would be that hard. Unless someone tells me it''s impossible or a bad idea, I''m going to try to add it in. If nothing else, it''ll help me to familiarize myself with the code and I can use the patch locally ;) Is there interest in this? Ben
Hi Ben, look at the docs for ActiveRecord::Base - you''ll find table_name_prefix (along with other options) there. Trevor On 24-Apr-05, at 11:17 PM, Ben Bleything wrote:> I''ve always wished that more apps shipped with the ability to specify > a table prefix... that is, a string that would be automatically > prepended to any table name in a database query. > > I''m currently hosting with a company that only allows one database, > and it would be nice to be able to install/develop/use multiple Rails > apps without worrying about table name collisions. > > Has anyone ever looked at this? Anyone ever done it? I haven''t dug > down into the ActiveRecord API much, and I''m absolutely a Rails > newbie, but I can''t imagine it would be that hard. > > Unless someone tells me it''s impossible or a bad idea, I''m going to > try to add it in. If nothing else, it''ll help me to familiarize > myself with the code and I can use the patch locally ;) > > Is there interest in this? > > Ben > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Apr 24, 2005, at 11:31 PM, Trevor Squires wrote:> Hi Ben, > > look at the docs for ActiveRecord::Base - you''ll find > table_name_prefix (along with other options) there.Thanks for pointing that out, Trevor! I should look before I ask, it seems. I guess what I''m wondering is this: would there be interest in making this easy to configure at an administrator level? ie, another field in the database.yml? I really hate going through other people''s code to make it work in my environment, since that''s almost always a recipe for disaster when it comes to upgrade time. Making it simple for the end-user to specify a prefix and letting Rails deal with the mojo seems like a pretty good idea to me. On the other hand, this could be an enhancement with a very small target audience and cause more trouble than its worth. I just don''t know, so here I am asking the world :) Ben
Well, I see what you mean about doing it in one place (not mucking with other people''s code)... I wonder if the setting could be done app-wide by sticking it into config/environment.rb? Trevor On 24-Apr-05, at 11:43 PM, Ben Bleything wrote:> On Apr 24, 2005, at 11:31 PM, Trevor Squires wrote: > >> Hi Ben, >> >> look at the docs for ActiveRecord::Base - you''ll find >> table_name_prefix (along with other options) there. > > Thanks for pointing that out, Trevor! I should look before I ask, it > seems. > > I guess what I''m wondering is this: would there be interest in making > this easy to configure at an administrator level? ie, another field > in the database.yml? I really hate going through other people''s code > to make it work in my environment, since that''s almost always a recipe > for disaster when it comes to upgrade time. > > Making it simple for the end-user to specify a prefix and letting > Rails deal with the mojo seems like a pretty good idea to me. On the > other hand, this could be an enhancement with a very small target > audience and cause more trouble than its worth. I just don''t know, so > here I am asking the world :) > > Ben > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Apr 24, 2005, at 11:52 PM, Trevor Squires wrote:> Well, I see what you mean about doing it in one place (not mucking > with other people''s code)... > > I wonder if the setting could be done app-wide by sticking it into > config/environment.rb?Works like a champ! Still feels a bit hacky, though. Ahh well, gets me past my initial hurdle, now I can actually start working on some stuff. Thanks! Ben