1 class User < ActiveRecord::Base
5 # Include default devise modules. Others available are:
6 # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
7 devise :database_authenticatable, :registerable,
8 :recoverable, :rememberable, :trackable, :validatable,
9 :omniauthable#, :confirmable
13 token = Devise.friendly_token
14 if token_suitable?(token)
15 self.authentication_token = token
22 def token_suitable?(token)
23 !self.class.exists?(authentication_token: token)
27 self.authentication_token = nil
34 self.author.scrolls.each do |scroll|
35 raise ActiveRecord::Rollback unless scroll.destroy_with_scroll_panel
37 self.author.panels.each do |panel|
38 raise ActiveRecord::Rollback unless panel.destroy_with_elements
41 self.artist.original_pictures.each do |original_picture|
42 raise ActiveRecord::Rollback unless original_picture.destroy_with_resource_picture
44 raise ActiveRecord::Rollback unless self.artist.destroy
46 raise ActiveRecord::Rollback unless self.author.destroy
47 raise ActiveRecord::Rollback unless super
55 params.require(:user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)