Skip to content

Commit

Permalink
Update example for recent versions of ActiveRecord
Browse files Browse the repository at this point in the history
`find_by_*` was replaced with `find_by(conditions_hash)` and `find_or_initialize_by_*` was replaced with `find_or_initialize_by(conditions_hash)`
  • Loading branch information
guilleiguaran committed Nov 6, 2016
1 parent 5a9b970 commit 355dc94
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 355dc94

Please sign in to comment.