Deprecate locking of dirty records #25873
I'd suggest to raise an exception, because that's easy to implement.
But thinking about it, there is a way that would just prevent the record from being dirty in the first place:
MyModel.where(attr: 42).first_with_lock! do |record| # change record record.save! end
On the other hand, this is more complicated, not as handy to use (you can't load the object, pass it to some other method, and lock it there), and might require major refactoring for the end users. So I'd still go with the exception.