This commit is contained in:
2025-05-15 03:01:22 +09:00
parent 4cf3fc4d8c
commit 2fb2daa3ff
3 changed files with 13 additions and 17 deletions
+4 -4
View File
@@ -4,10 +4,7 @@ class Tag < ApplicationRecord
has_many :tag_aliases, dependent: :destroy
has_many :wiki_pages, dependent: :nullify
validates :name, presence: true, length: { maximum: 255 }
validates :category, presence: true, inclusion: { in: categories.keys }
enum category: { deerjikist: 'deerjikist',
enum :category, { deerjikist: 'deerjikist',
meme: 'meme',
character: 'character',
general: 'general',
@@ -15,5 +12,8 @@ class Tag < ApplicationRecord
nico: 'nico',
meta: 'meta' }
validates :name, presence: true, length: { maximum: 255 }
validates :category, presence: true, inclusion: { in: Tag.categories.keys }
scope :nico_tags, -> { where category: :nico }
end
+4 -8
View File
@@ -1,11 +1,11 @@
class User < ApplicationRecord
enum :role, { guest: 'guest', member: 'member', admin: 'admin' }
validates :name, length: { maximum: 255 }
validates :inheritance_code, presence: true, length: { maximum: 64 }
validates :role, presence: true, inclusion: { in: roles.keys }
validates :banned, inclusion: { in: [true, false] }
enum role: { guest: 'guest', member: 'member', admin: 'admin' }
has_many :posts
has_many :settings
has_many :ip_addresses
@@ -13,12 +13,8 @@ class User < ApplicationRecord
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 }
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