#2 修正
This commit is contained in:
@@ -4,10 +4,7 @@ class Tag < ApplicationRecord
|
|||||||
has_many :tag_aliases, dependent: :destroy
|
has_many :tag_aliases, dependent: :destroy
|
||||||
has_many :wiki_pages, dependent: :nullify
|
has_many :wiki_pages, dependent: :nullify
|
||||||
|
|
||||||
validates :name, presence: true, length: { maximum: 255 }
|
enum :category, { deerjikist: 'deerjikist',
|
||||||
validates :category, presence: true, inclusion: { in: categories.keys }
|
|
||||||
|
|
||||||
enum category: { deerjikist: 'deerjikist',
|
|
||||||
meme: 'meme',
|
meme: 'meme',
|
||||||
character: 'character',
|
character: 'character',
|
||||||
general: 'general',
|
general: 'general',
|
||||||
@@ -15,5 +12,8 @@ class Tag < ApplicationRecord
|
|||||||
nico: 'nico',
|
nico: 'nico',
|
||||||
meta: 'meta' }
|
meta: 'meta' }
|
||||||
|
|
||||||
|
validates :name, presence: true, length: { maximum: 255 }
|
||||||
|
validates :category, presence: true, inclusion: { in: Tag.categories.keys }
|
||||||
|
|
||||||
scope :nico_tags, -> { where category: :nico }
|
scope :nico_tags, -> { where category: :nico }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
|
enum :role, { guest: 'guest', member: 'member', admin: 'admin' }
|
||||||
|
|
||||||
validates :name, length: { maximum: 255 }
|
validates :name, length: { maximum: 255 }
|
||||||
validates :inheritance_code, presence: true, length: { maximum: 64 }
|
validates :inheritance_code, presence: true, length: { maximum: 64 }
|
||||||
validates :role, presence: true, inclusion: { in: roles.keys }
|
validates :role, presence: true, inclusion: { in: roles.keys }
|
||||||
validates :banned, inclusion: { in: [true, false] }
|
validates :banned, inclusion: { in: [true, false] }
|
||||||
|
|
||||||
enum role: { guest: 'guest', member: 'member', admin: 'admin' }
|
|
||||||
|
|
||||||
has_many :posts
|
has_many :posts
|
||||||
has_many :settings
|
has_many :settings
|
||||||
has_many :ip_addresses
|
has_many :ip_addresses
|
||||||
@@ -13,12 +13,8 @@ class User < ApplicationRecord
|
|||||||
has_many :ip_addresses, through: :user_ips
|
has_many :ip_addresses, through: :user_ips
|
||||||
has_many :user_post_views, dependent: :destroy
|
has_many :user_post_views, dependent: :destroy
|
||||||
has_many :viewed_posts, through: :user_post_views, source: :post
|
has_many :viewed_posts, through: :user_post_views, source: :post
|
||||||
has_many :created_wiki_pages, { class_name: 'WikiPage',
|
has_many :created_wiki_pages, class_name: 'WikiPage', foreign_key: 'created_user_id', dependent: :nullify
|
||||||
foreign_key: 'created_user_id',
|
has_many :updated_wiki_pages, class_name: 'WikiPage', foreign_key: 'updated_user_id', dependent: :nullify
|
||||||
dependent: :nullify }
|
|
||||||
has_many :updated_wiki_pages, { class_name: 'WikiPage',
|
|
||||||
foreign_key: 'updated_user_id',
|
|
||||||
dependent: :nullify }
|
|
||||||
|
|
||||||
def viewed? post
|
def viewed? post
|
||||||
user_post_views.exists? post_id: post.id, viewed: true
|
user_post_views.exists? post_id: post.id, viewed: true
|
||||||
|
|||||||
Reference in New Issue
Block a user