app/models/user.rb in artfully_ose-1.0.0.rc4 vs app/models/user.rb in artfully_ose-1.1.0.rc1
- old
+ new
@@ -1,13 +1,14 @@
-class User < ActiveRecord::Base
+ class User < ActiveRecord::Base
include Ext::DeviseConfiguration
include Ext::Integrations::User
has_many :shows
has_many :orders
has_many :imports
+ has_many :discounts
has_many :memberships
has_many :organizations, :through => :memberships
scope :logged_in_more_than_once, where("users.sign_in_count > 1")
@@ -32,8 +33,15 @@
end
def self.like(query = "")
return if query.blank?
q = "%#{query}%"
- self.joins("LEFT OUTER JOIN memberships ON memberships.user_id = users.id").joins("LEFT OUTER JOIN organizations ON organizations.id = memberships.organization_id").where("email like ? or organizations.name like ?", q, q)
+ self.joins("LEFT OUTER JOIN memberships m ON m.user_id = users.id")
+ .joins("LEFT OUTER JOIN organizations o ON o.id = m.organization_id")
+ .includes(:organizations)
+ .where("users.email like ? or o.name like ?", q, q)
+ end
+
+ def active_for_authentication?
+ super && !suspended?
end
end