开发者

Specify a table prefix for MySQL

开发者 https://www.devze.com 2022-12-27 06:32 出处:网络
In CakePHP, I can specify a prefix in my database configuration, i.e. \"so_\", so that every model looks for开发者_StackOverflow its table under this prefix.

In CakePHP, I can specify a prefix in my database configuration, i.e. "so_", so that every model looks for开发者_StackOverflow its table under this prefix.

Is something similar possible in Rails, too? That is, can several programs share one database?


You might try the following in environments.rb: In the config section add the following code

config.active_record.table_name_prefix = "so_"


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

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

But you have to do it for each model, I don´t know of any global configuration option.

0

精彩评论

暂无评论...
验证码 换一张
取 消