add geo info and do refractor on workers
This commit is contained in:
@@ -9,6 +9,8 @@ class WowCharacter < ApplicationRecord
|
||||
belongs_to :wow_class
|
||||
belongs_to :wow_race
|
||||
belongs_to :wow_character_title, optional: true
|
||||
belongs_to :last_position, class_name: 'WowGeoPosition', optional: true
|
||||
belongs_to :bind_position, class_name: 'WowGeoPosition', optional: true
|
||||
has_one :wow_character_medium, dependent: :nullify
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
11
app/models/wow_geo_map.rb
Normal file
11
app/models/wow_geo_map.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WowGeoMap < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name
|
||||
|
||||
has_many :wow_geo_positions, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :map_id, presence: true, uniqueness: true
|
||||
end
|
||||
21
app/models/wow_geo_position.rb
Normal file
21
app/models/wow_geo_position.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WowGeoPosition < ApplicationRecord
|
||||
belongs_to :wow_geo_map
|
||||
belongs_to :wow_geo_zone
|
||||
|
||||
has_one(
|
||||
:last_position_character,
|
||||
class_name: 'WowCharacter',
|
||||
foreign_key: 'last_position_id',
|
||||
inverse_of: :last_position,
|
||||
dependent: :destroy
|
||||
)
|
||||
has_one(
|
||||
:bind_position_character,
|
||||
class_name: 'WowCharacter',
|
||||
foreign_key: 'bind_position_id',
|
||||
inverse_of: :bind_position,
|
||||
dependent: :destroy
|
||||
)
|
||||
end
|
||||
11
app/models/wow_geo_zone.rb
Normal file
11
app/models/wow_geo_zone.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WowGeoZone < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name
|
||||
|
||||
has_many :wow_geo_positions, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :zone_id, presence: true, uniqueness: true
|
||||
end
|
||||
Reference in New Issue
Block a user