Hacker News new | ask | show | jobs
by ned 5472 days ago
Interesting.

For the example cited, you could also use ActiveRecord::Dirty

  def clean_summary
    self.summary = summary.squish if self.summary_changed?
  end
1 comments

Not 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.