Does *_changed_to?(value) make sense?

In many cases I see this kind of condition:

if status_id_changed? && status_id == Status::ACCEPTED

So maybe it will be nice to introduce a new method like:

if status_id_changed_to?(Status::ACCEPTED)

I use this kind of conditional around the place too.

I’m -1 on adding more dynamic methods though. I’d sooner see something like #changed? extended:

p = Person.new p.name = ‘Nicholas’ p.changed? => true p.changed?(:name) => true p.changed?(:age) => false p.changed?(name: ‘Nicholas’) => true p.changed?(name: ‘Nick’) => false

What do you think?

If this is happening, it might be nice to test on both the old and the new value

p.changed?(name: {“Nick” => “Nicholas”})

I’ve created a pull request to make this happen.

https://github.com/rails/rails/pull/13131

model.name_changed?(“Ringo”) model.name_changed?(“John” => “Ringo”)