Class: Alliance

Inherits:
Object
  • Object
show all
Includes:
MongoidSetup
Defined in:
lib/generators/rails_eve/install/templates/alliance.rb

Class Method Summary collapse

Class Method Details

.create_from_api(alliance_id) ⇒ Object



18
19
20
21
# File 'lib/generators/rails_eve/install/templates/alliance.rb', line 18

def self.create_from_api(alliance_id)
  api_alliance = ESI::AllianceApi.new.get_alliances_alliance_id(alliance_id)
  where(id: alliance_id, name: api_alliance.name, ticker: api_alliance.ticker).first_or_create
end

.update_counter_cachesObject



11
12
13
14
15
16
# File 'lib/generators/rails_eve/install/templates/alliance.rb', line 11

def self.update_counter_caches
  all.each do |user|
    user.characters_count = user.characters.count
    user.save
  end
end