Module: ElabsMatchers::Helpers::ReloadRecord
- Defined in:
- lib/elabs_matchers/helpers/reload_record.rb
Instance Method Summary collapse
-
#reload(record) ⇒ Object
Finds the record from the database and return a new instance for that record.
-
#save_and_reload(record) ⇒ Object
Saves the record and fetches it from the database and return a new instance for that record.
Instance Method Details
#reload(record) ⇒ Object
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 |
#save_and_reload(record) ⇒ Object
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 |