app/models/guts/user.rb in guts-1.0.8 vs app/models/guts/user.rb in guts-1.1.0
- old
+ new
@@ -4,26 +4,28 @@
include TrackableConcern
# Regex to test email against for validation
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
- validates :name, presence: true, length: {maximum: 50}
+ validates :name, presence: true, length: { maximum: 50 }
validates :email,
- presence: true,
- length: {maximum: 255},
- format: {with: VALID_EMAIL_REGEX},
- uniqueness: {case_sensitive: false}
- validates :password, presence: true, length: {minimum: 6}, allow_nil: true
+ presence: true,
+ length: { maximum: 255 },
+ format: { with: VALID_EMAIL_REGEX },
+ uniqueness: { case_sensitive: false }
+ validates :password, presence: true, length: { minimum: 6 }, allow_nil: true
has_secure_password
has_many :media, as: :filable, dependent: :destroy
has_many :metafields, as: :fieldable, dependent: :destroy
has_many :user_groups
has_many :groups, through: :user_groups
has_many :tracks, as: :object
has_many :contents
trackable :create, :update, :destroy, fields: [:name, :group_id]
+
+ scope :in_group, -> (group) { includes(:groups).where(guts_groups: { id: group.id }) }
# Setter override for email to downcase and strip email before database
def email=(email)
self[:email] = email.downcase.strip
end