Sha256: 07c55b43bf93ab91e1fb026fa4ea21ff19bf0f5aba98ec0f0c8fdbbb4c64b9f1
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
ActiveRecord::Schema.define do create_table :users, :force => true do |t| t.string :name end create_table :posts_users, :id => false, :force => true do |t| t.references :user, :null => false t.references :post, :null => false end create_table :posts, :force => true do |t| t.string :content end create_table :connections, :force => true do |t| t.references :user t.references :friend end create_table :friends, :force => true do |t| t.string :type end end class User < ActiveRecord::Base has_and_belongs_to_many :posts if ActiveRecord::VERSION::MAJOR >= 4 has_and_belongs_to_many :posts_without_content, -> { where(content: nil) }, class_name: 'Post' end has_many :connections has_many :friends, :through => :connections end class Post < ActiveRecord::Base has_and_belongs_to_many :users end class Connection < ActiveRecord::Base has_many :friends has_many :users end class Friend < ActiveRecord::Base has_many :connections has_many :users, :through => :connections end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
m2m_fast_insert-0.3.0 | spec/support/test_model.rb |