Don't error when deleting supplier/group with already existing deleted name (closes foodcoops/foodsoft#197)

This commit is contained in:
wvengen 2015-04-17 20:05:46 +02:00
parent b028431bf0
commit 17cbc57850
3 changed files with 33 additions and 3 deletions

View file

@ -1,5 +1,7 @@
# encoding: utf-8
class Supplier < ActiveRecord::Base
include MarkAsDeletedWithName
has_many :articles, -> { where(:type => nil).includes(:article_category).order('article_categories.name', 'articles.name') }
has_many :stock_articles, -> { includes(:article_category).order('article_categories.name', 'articles.name') }
has_many :orders
@ -109,7 +111,7 @@ class Supplier < ActiveRecord::Base
def mark_as_deleted
transaction do
update_column :deleted_at, Time.now
super
articles.each(&:mark_as_deleted)
end
end