add more intelligent js for artist forms

This commit is contained in:
Albert Yi
2016-10-18 14:53:44 -07:00
parent 2424f24fcd
commit 2a5343b8cf
7 changed files with 45 additions and 37 deletions

View File

@@ -8,6 +8,7 @@ class Artist < ActiveRecord::Base
after_save :categorize_tag
validates_uniqueness_of :name
validate :name_is_valid
validate :wiki_is_empty, :on => :create
belongs_to :creator, :class_name => "User"
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl"
@@ -252,6 +253,13 @@ class Artist < ActiveRecord::Base
def notes_changed?
!!@notes_changed
end
def wiki_is_empty
if WikiPage.titled(name).exists?
errors.add(:name, "conflicts with a wiki page")
return false
end
end
end
module TagMethods