Guest User

Untitled

a guest
Oct 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. `class CreateSectionEdits < ActiveRecord::Migration[5.2]`
  2. `def up`
  3. `create_table :section_edits do |t|`
  4. t.integer "admin_user_id"
  5. t.integer "section_id"
  6. t.string "summary"
  7. t.timestamps
  8. end
  9. add_index("section_edits", ["admin_user_id", "section_id"])
  10. end
  11.  
  12. def down
  13. drop_table :section_edits
  14. end
  15. end
  16. `
  17.  
  18. class SectionEdit < ApplicationRecord
  19.  
  20. belongs_to :admin_users, optional: true
  21. belongs_to :section
  22. end
  23.  
  24. class AdminUser < ApplicationRecord
  25.  
  26. #self.table_name = "admin_users"
  27.  
  28. has_and_belongs_to_many :pages
  29. has_many :section_edits
  30.  
  31.  
  32. end
  33.  
  34. class Section < ApplicationRecord
  35. belongs_to :page, { :optional => false}
  36. has_many :section_edits
  37.  
  38. end
Add Comment
Please, Sign In to add comment