Fix old find_or_initialize_by methods
I missed this in the Rails upgrades, oops!
This commit is contained in:
parent
f21a7da362
commit
1e690d9f6c
3 changed files with 10 additions and 10 deletions
|
@ -50,7 +50,7 @@ class NeopetsUser
|
|||
|
||||
pets_data = envelope.messages[0].data.body
|
||||
raise NotFound if pets_data == false
|
||||
pets = pets_data.map { |pet| Pet.find_or_initialize_by_name(pet['name']) }
|
||||
pets = pets_data.map { |pet| Pet.find_or_initialize_by(name: pet['name']) }
|
||||
items = pets.each(&:load!).map(&:items).flatten
|
||||
item_ids = items.map(&:id)
|
||||
item_quantities = {}
|
||||
|
|
|
@ -31,9 +31,9 @@ class Pet < ApplicationRecord
|
|||
|
||||
pet_data = viewer_data[:custom_pet]
|
||||
|
||||
self.pet_type = PetType.find_or_initialize_by_species_id_and_color_id(
|
||||
pet_data[:species_id].to_i,
|
||||
pet_data[:color_id].to_i
|
||||
self.pet_type = PetType.find_or_initialize_by(
|
||||
species_id: pet_data[:species_id].to_i,
|
||||
color_id: pet_data[:color_id].to_i
|
||||
)
|
||||
self.pet_type.body_id = pet_data[:body_id]
|
||||
self.pet_type.origin_pet = self
|
||||
|
@ -166,13 +166,13 @@ class Pet < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.load(name, options={})
|
||||
pet = Pet.find_or_initialize_by_name(name)
|
||||
pet = Pet.find_or_initialize_by(name: name)
|
||||
pet.load!(options)
|
||||
pet
|
||||
end
|
||||
|
||||
def self.from_viewer_data(viewer_data, options={})
|
||||
pet = Pet.find_or_initialize_by_name(viewer_data[:custom_pet][:name])
|
||||
pet = Pet.find_or_initialize_by(name: viewer_data[:custom_pet][:name])
|
||||
pet.use_viewer_data(viewer_data, options)
|
||||
pet
|
||||
end
|
||||
|
|
|
@ -162,10 +162,10 @@ class PetState < ApplicationRecord
|
|||
if pet_type.new_record?
|
||||
pet_state = self.new :swf_asset_ids => swf_asset_ids_str
|
||||
else
|
||||
pet_state = self.find_or_initialize_by_pet_type_id_and_swf_asset_ids(
|
||||
pet_type.id,
|
||||
swf_asset_ids_str
|
||||
)
|
||||
pet_state = self.find_or_initialize_by(
|
||||
pet_type_id: pet_type.id,
|
||||
swf_asset_ids: swf_asset_ids_str
|
||||
)
|
||||
end
|
||||
existing_swf_assets = SwfAsset.biology_assets.includes(:zone).
|
||||
find_all_by_remote_id(swf_asset_ids)
|
||||
|
|
Loading…
Reference in a new issue