This commit is contained in:
2025-05-15 02:21:42 +09:00
parent 137c86bba7
commit 4cf3fc4d8c
12 changed files with 124 additions and 57 deletions
+14
View File
@@ -9,4 +9,18 @@ class User < ApplicationRecord
has_many :posts
has_many :settings
has_many :ip_addresses
has_many :user_ips, dependent: :destroy
has_many :ip_addresses, through: :user_ips
has_many :user_post_views, dependent: :destroy
has_many :viewed_posts, through: :user_post_views, source: :post
has_many :created_wiki_pages, { class_name: 'WikiPage',
foreign_key: 'created_user_id',
dependent: :nullify }
has_many :updated_wiki_pages, { class_name: 'WikiPage',
foreign_key: 'updated_user_id',
dependent: :nullify }
def viewed? post
user_post_views.exists? post_id: post.id, viewed: true
end
end