Guest User

Untitled

a guest
Jan 12th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. class Serial < ActiveRecord::Base
  2. has_attached_file :cover
  3. has_many :serial_seasons, :dependent => :delete_all
  4. has_many :episodes, :through => :serial_seasons, :dependent => :delete_all
  5.  
  6. validates :title, :uniqueness => true, :presence => true
  7. validates :description, :uniqueness => true, :presence => true
  8. validates :cover_file_name, :presence => true
  9. validates :started_at, :presence => true
  10.  
  11. def to_label
  12. "#{title}"
  13. end
  14.  
  15. end
  16.  
  17. class SerialSeason < ActiveRecord::Base
  18. belongs_to :serial
  19. has_many :episodes, :dependent => :delete_all
  20.  
  21. validates :title, :presence => true
  22. validates :serial_id, :presence => true
  23.  
  24. def to_label
  25. "#{title}"
  26. end
  27.  
  28. end
  29.  
  30. class Episode < ActiveRecord::Base
  31. belongs_to :serial_season
  32. belongs_to :serial
  33.  
  34. validates :title, :presence => true
  35. validates :serial_id, :presence => true
  36. validates :serial_season_id, :presence => true
  37. validates :vk_frame, :uniqueness => true, :presence => true
  38.  
  39. def to_label
  40. "#{title}"
  41. end
  42.  
  43. end
Add Comment
Please, Sign In to add comment