OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / models / user.rb
index 48a344c..d59f35e 100644 (file)
@@ -1,5 +1,6 @@
 class User < ActiveRecord::Base
   has_one :author
+  has_one :artist
   
   # Include default devise modules. Others available are:
   # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
@@ -28,11 +29,11 @@ class User < ActiveRecord::Base
       self.author.panels.each do |panel|
         raise ActiveRecord::Rollback unless panel.destroy_with_elements
       end
-      if self.author.artist
-        self.author.artist.original_pictures.each do |original_picture|
+      if self.artist
+        self.artist.original_pictures.each do |original_picture|
           raise ActiveRecord::Rollback unless original_picture.destroy_with_resource_picture
         end
-        raise ActiveRecord::Rollback unless self.author.artist.destroy
+        raise ActiveRecord::Rollback unless self.artist.destroy
       end
       raise ActiveRecord::Rollback unless self.author.destroy
       raise ActiveRecord::Rollback unless super