#2 完了
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user