Class: CamaleonCms::UniqValidatorUser
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- CamaleonCms::UniqValidatorUser
- Defined in:
- app/models/camaleon_cms/user.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
10 11 12 13 14 |
# File 'app/models/camaleon_cms/user.rb', line 10 def validate(record) record.errors[:base] << "#{I18n.t('camaleon_cms.admin.users.message.requires_different_username')}" if CamaleonCms::User.where(username: record.username).where.not(id: record.id).where("#{CamaleonCms::User.table_name}.site_id" => record.site_id).size > 0 record.errors[:base] << "#{I18n.t('camaleon_cms.admin.users.message.requires_different_email')}" if CamaleonCms::User.where(email: record.email).where.not(id: record.id).where("#{CamaleonCms::User.table_name}.site_id" => record.site_id).size > 0 end |