Skip to content

Commit

Permalink
Merge pull request #664 from guilleiguaran/patch-1
Browse files Browse the repository at this point in the history
Update example for recent versions of ActiveRecord
  • Loading branch information
antstorm committed Nov 7, 2016
2 parents 5a9b970 + 355dc94 commit b07a9d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ The following example implements an `ActiveRecord` store to save exchange rates

class ExchangeRate < ActiveRecord::Base
def self.get_rate(from_iso_code, to_iso_code)
rate = find_by_from_and_to(from_iso_code, to_iso_code)
rate = find_by(:from => from_iso_code, :to => to_iso_code)
rate.present? ? rate.rate : nil
end

def self.add_rate(from_iso_code, to_iso_code, rate)
exrate = find_or_initialize_by_from_and_to(from_iso_code, to_iso_code)
exrate = find_or_initialize_by(:from => from_iso_code, :to => to_iso_code)
exrate.rate = rate
exrate.save!
end
Expand Down

0 comments on commit b07a9d9

Please sign in to comment.