上映会のし組み作り(#295) (#296)

#295

#295

#295

#295

#295

#295

#295

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #296
This commit was merged in pull request #296.
This commit is contained in:
2026-03-18 23:01:04 +09:00
parent ffadd03c49
commit 8cf7107445
19 changed files with 858 additions and 61 deletions
+13
View File
@@ -0,0 +1,13 @@
class Theatre < ApplicationRecord
include MyDiscard
has_many :comments, class_name: 'TheatreComment'
has_many :theatre_watching_users, dependent: :delete_all
has_many :active_theatre_watching_users, -> { active },
class_name: 'TheatreWatchingUser', inverse_of: :theatre
has_many :watching_users, through: :active_theatre_watching_users, source: :user
belongs_to :host_user, class_name: 'User', optional: true
belongs_to :current_post, class_name: 'Post', optional: true
belongs_to :created_by_user, class_name: 'User'
end
+8
View File
@@ -0,0 +1,8 @@
class TheatreComment < ApplicationRecord
include MyDiscard
self.primary_key = :theatre_id, :no
belongs_to :theatre
end
@@ -0,0 +1,13 @@
class TheatreWatchingUser < ApplicationRecord
self.primary_key = :theatre_id, :user_id
belongs_to :theatre
belongs_to :user
scope :active, -> { where('expires_at >= ?', Time.current) }
scope :expired, -> { where('expires_at < ?', Time.current) }
def active? = expires_at >= Time.current
def refresh! = update!(expires_at: 30.seconds.from_now)
end