Specify table prefix for MySQL

In CakePHP, I can specify a prefix in my database configuration, i.e. "so_", so that each model searches for its own table under this prefix.

Is this possible in Rails? That is, can several programs share the same database?

+6
ruby-on-rails prefix
source share
3 answers

You can try the following in environments.rb : In the configuration section, add the following code

 config.active_record.table_name_prefix = "so_" 
+12
source share

You can easily specify your own table name for each model using the set_table_name method:

 class Mouse < ActiveRecord::Base set_table_name "so_mice" end 

But you have to do this for each model, I do not know any global configuration.

0
source share

The RAILS_ENV constant has been deprecated since version 3.0, now it is Rails.env

0
source share

All Articles