KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Let's say that we have a method inside a model that needs to called only on saved records may update the model itself and thus the model needs to be saved again afterwords Should the "save" calls happen inside the method itself like the following code def result save! if new_record? # do some funky stuff here that may also change the model state # ... # And calculate the return value search_result = "foo" # Let's say "foo" is the value we calculated save! if changed? search_result # return end Or should the external observer (the controller) be responsible for calling save as needed?
Tags (comma-separated)
Save Edits
Cancel