Module: ElabsMatchers::Helpers::ReloadRecord

Defined in:
lib/elabs_matchers/helpers/reload_record.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) reload(record)

Finds the record from the database and return a new instance for that record.

Example: reload(post)

Parameters:

  • record (Object)

    An instance of an ORM record



15
16
17
# File 'lib/elabs_matchers/helpers/reload_record.rb', line 15

def reload(record)
  record.class.find(record.id)
end

- (Object) save_and_reload(record)

Saves the record and fetches it from the database and return a new instance for that record.

Example: save_and_reload(post)

Parameters:

  • record (Object)

    An instance of an ORM record



28
29
30
31
# File 'lib/elabs_matchers/helpers/reload_record.rb', line 28

def save_and_reload(record)
  record.save!
  reload(record)
end