class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:RemoteUser] validates :name, presence: true validates :email, presence: true, uniqueness: true validates :provider, presence: true, unless: Proc.new { |user| user.uid.nil? || user.uid.blank? } validates :uid, presence: true, uniqueness: { scope: :provider }, unless: Proc.new { |user| user.provider.nil? || user.provider.blank? } has_many :project_attributes, class_name: 'ProjectAttributes', dependent: :destroy has_many :reading_group_attributes, class_name: 'ReadingGroupAttributes', dependent: :destroy has_many :repository_attributes, class_name: 'RepositoryAttributes', dependent: :destroy has_many :kalibro_configuration_attributes, class_name: 'KalibroConfigurationAttributes', dependent: :destroy # Alert: when adding new parameters to this model, they should also be added to registrations_controller def projects project_attributes.map { |project_attr| project_attr.project } end protected def password_required? provider.nil? && super end end