Hey, I have a hosting where I can have only 1 database (shame on them!) On that hosting I want to run 2 application, but those application has the same models like user.rb (table: users) role.rb -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, I have a hosting where I can have only 1 database (shame on them!) On that hosting I want to run 2 application, but those application has the same models like user.rb (table: users) role.rb (table: roles) I have 2 Applcation A and B, and i want to run them at the same time. So i will do this sort of solution (not very handy) For each application I when put an extra letter in the tables names Appliction A: a_users and a_roles Appliction B: b_users and b_roles This mean that I need to rename all me class to a_user.rb a_role.rb b_user.rb b_role.rb And everywhere i use it :s:s:s Isnt there something where i can say per model the tablename Like: a_user.rb tablename => a_users a_role.rb tablename => a_roles b_user.rb tablename => b_users b_role.rb tablename => b_roles Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brutyn Nick wrote:> Hey, > > I have a hosting where I can have only 1 database (shame on them!) > On that hosting I want to run 2 application, but those application has > the same models like > > user.rb (table: users) > role.rb (table: roles) > > I have 2 Applcation A and B, and i want to run them at the same time. So > i will do this sort of solution (not very handy) > > For each application I when put an extra letter in the tables names > > Appliction A: a_users and a_roles > Appliction B: b_users and b_roles > > This mean that I need to rename all me classNah. First of all you can use ActiveRecord::Base.set_table_name to set the name of a models table regardless of the name of the model. But perhaps even easier would be to use ActiveRecord::Base.table_name_prefix to set a global prefix for all your tables. Dunno if this is actually easier in your case. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can use table_name_prefix (part of your app''s config) to set a prefix for table names on a per application basis (see http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet), or you can use set_table_name if you want to change a model''s table name on a per-model basis. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> You can use table_name_prefix (part of your app''s config) to set a > prefix for table names on a per application basis (see > http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet), > or you can use set_table_name if you want to change a model''s table name > on a per-model basis. > > FredHey, I want to have each table this prefix => "d_" But where do i need to put this: Rails::Initializer do |config| config.table_name_prefix = "d_" end Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 11/4/06, Brutyn Nick <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hey, > > I have a hosting where I can have only 1 database (shame on them!) > On that hosting I want to run 2 application, but those application has > the same models like > > user.rb (table: users) > role.rbHey, one problem with this is that if you''re using migrations (which you should be), the migrations will conflict. i.e. let''s say you run app a''s migrations, then app b will think the schema is up to that number, which may not be good for app b. I wrote a plugin to take care of this by recording the schema info separately for each app you want to run. http://svn.flpr.org/public/plugins/app_migrations/README Basically you just install the plugin, and in your environment.rb file add ActiveRecord::Base.app_migration(:my_app_name) Also if you set ActiveRecord::Base.table_name_prefix then all your tables will have a prefix so there won''t be naming conflicts. With all this set up you can develop with migrations and not worry about any kind of migration or naming conflicts. hth Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In your app''s config.rb Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks that works -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---