| 
				
				
					
				
				
				 | 
			
			 | 
			@@ -15,5 +15,15 @@ class Tag < ApplicationRecord | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  validates :name, presence: true, length: { maximum: 255 } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  validates :category, presence: true, inclusion: { in: Tag.categories.keys } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  validate :nico_tag_name_must_start_with_nico | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  scope :nico_tags, -> { where category: :nico } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  private | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  def nico_tag_name_must_start_with_nico | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    if category == 'nico' && name&.[](0, 5) != 'nico:' | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      errors.add :name, 'ニコニコ・タグの命名規則に反してゐます.' | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    end | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  end | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			end |