A few tips that come into my mind:
extract SunspotExtract Sunspot search logic to a separate class, it's. It's not really usera user's concern: https://github.com/sunspot/sunspot/wiki/Setting-up-classes-for-search-and-indexing.
inlineInline some scopes, i.e.:
scope :with_dependents, -> { includes(:common_app, :video, :applications, :jobs) }
scope :with_dependents, -> { includes(:common_app, :video, :applications, :jobs) }
(thisThis is actually more readable in my opinion.)
extractExtract password management and encryption to separate class (again, not really userthe user's concern):
class PasswordManager attr_reader :user
def initialize(user) @user = user end
def generate_password user.password = ("a".."z").to_a.sample(8).join("") end end
class PasswordManager attr_reader :user def initialize(user) @user = user end def generate_password user.password = ("a".."z").to_a.sample(8).join("") end end
Hope it helps.