daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class CreateCompanyMembers < ActiveRecord::Migration
  2.   def self.up
  3.     create_table :company_members do |t|
  4.       t.integer :company_id
  5.       t.integer :member_id
  6.       t.string :role
  7.  
  8.       t.timestamps
  9.     end
  10.   end
  11.  
  12.   def self.down
  13.     drop_table :company_members
  14.   end
  15. end
  16.  
  17. class CompanyMember < ActiveRecord::Base
  18.   belongs_to :company
  19.   belongs_to :member
  20. end
  21.  
  22.  
  23. class Member < ActiveRecord::Base
  24.   has_many :company_members
  25.   has_many :companies, :through => :company_members
  26. end
  27.  
  28. class Company < ActiveRecord::Base
  29.   has_many :company_members
  30.   has_many :members, :through => :company_members
  31. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top