Module: ElabsMatchers::Helpers::ReloadRecord
- Defined in:
- lib/elabs_matchers/helpers/reload_record.rb
Instance Method Summary (collapse)
-
- (Object) reload(record)
Finds the record from the database and return a new instance for that record.
-
- (Object) save_and_reload(record)
Saves the record and fetches it from the database and return a new instance for that record.
Instance Method Details
- (Object) reload(record)
Finds the record from the database and return a new instance for that record.
Example: reload(post)
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)
28 29 30 31 |
# File 'lib/elabs_matchers/helpers/reload_record.rb', line 28 def save_and_reload(record) record.save! reload(record) end |