Using multiple PostgreSQL schemas with Rails models

后端 未结 6 1937
挽巷
挽巷 2020-12-07 12:01

I have a PostgreSQL database for my Rails application. In the schema named \'public\' the main Rails models tables are stored etc. I have created a \'discogs\' schema which

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 12:40

    The correct one for rails 4.2 is as:

    class Foo < ActiveRecord::Base
      self.table_name = 'myschema.foo'
    end
    

    More info -http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-table_name-3D

提交回复
热议问题