artists: show success/error message when updating artists.

This commit is contained in:
evazion
2017-07-29 01:38:21 -05:00
parent 6121b8cb25
commit 10614d2152
2 changed files with 9 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ class ArtistsController < ApplicationController
def update
@artist.update(params[:artist], :as => CurrentUser.role)
flash[:notice] = @artist.valid? ? "Artist updated" : @artist.errors.full_messages.join("; ")
respond_with(@artist)
end

View File

@@ -10,6 +10,7 @@ class Artist < ApplicationRecord
validates_uniqueness_of :name
validate :validate_name
validate :validate_wiki, :on => :create
after_validation :merge_validation_errors
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"
@@ -535,6 +536,13 @@ class Artist < ApplicationRecord
extend SearchMethods
include ApiMethods
def merge_validation_errors
errors[:urls].clear
urls.select(&:invalid?).each do |url|
errors[:url] << url.errors.full_messages.join("; ")
end
end
def status
if is_banned? && is_active?
"Banned"