4 ms·
Interesting. For the example cited, you could also use ActiveRecord::Dirty def clean_summary self.summary = summary.squish if self.summary_changed? en
by ned 15y ago
Interesting.
For the example cited, you could also use ActiveRecord::Dirty
def clean_summary
self.summary = summary.squish if self.summary_changed?
end
- laserlemon 15y agoNot quite because the summary could change to nil, but it brings up a good point. There's often a better way in Rails, but &&= is native Ruby so it's especially useful in non-Rails applications.