OSDN Git Service

fix: devise
[pettanr/pettanr.git] / app / models / user.rb
index 5c80960..f6b0cdf 100644 (file)
@@ -1,13 +1,12 @@
 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
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable
-
-  # Setup accessible (or protected) attributes for your model
-  attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
+         :recoverable, :rememberable, :trackable,  :validatable, 
+         :omniauthable#, :confirmable
 
   def create_token
     self.ensure_authentication_token
@@ -22,17 +21,17 @@ class User < ActiveRecord::Base
   def destroy
     res = false
     User.transaction do
-      self.author.comics.each do |comic|
-        raise ActiveRecord::Rollback unless comic.destroy_with_story
+      self.author.scrolls.each do |scroll|
+        raise ActiveRecord::Rollback unless scroll.destroy_with_scroll_panel
       end
       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
@@ -41,4 +40,9 @@ class User < ActiveRecord::Base
     res
   end
   
+  private
+  def user_params
+    params.require(:user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)
+  end
+  
 end