Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Fix data not being save
Browse files Browse the repository at this point in the history
  • Loading branch information
bartkozal committed Jan 23, 2019
1 parent afd0746 commit f1e37d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/game.rb
Expand Up @@ -7,11 +7,11 @@ class Game < ApplicationRecord

def self.save_igdb_results(results)
IGDB.parse(results).map do |game_attributes|
game = find_or_initialize_by(igdb: game_attributes[:igdb])
if game.new_record?
game.save
else
if game = find_by(igdb: game_attributes[:igdb])
game.update(game_attributes)
else
game = new(game_attributes)
game.save
end
game.id
end
Expand Down

0 comments on commit f1e37d0

Please sign in to comment.