This patch allows users to create a field named field in AR models.
Without this patch, AR raises ActiveRecord::DangerousAttributeError: field_changed? is defined by ActiveRecord when trying to define a "_changed?" suffixed method for every attribute https://github.com/rails/rails/blob/b454601/activemodel/lib/active_model/dirty.rb#L92
ActiveRecord::DangerousAttributeError: field_changed? is defined by ActiveRecord
This should be fixed because
1) "field" fields didn't cause any error on AR 2. So, this is a regression.
2) AR's field_changed? is a private method. Why should attribute names be restricted by the framework's internal method name?
Seems good, but shouldn't we have a test to ensure against another regression?
A test case for GH #3544 to ensure that a field named field works fine
@tenderlove Thank you for reviewing. Just added a test case that fails without fdfe358.
Rename field_changed? to _field_changed? so that users can create a f…
…ield named field
Rebased against current master. @tenderlove, could you merge this?
I don't see this in the 3-2-stable branch so I assume it hasn't been backported. Could someone backport it? Would be hell of useful.
@clemens see #7723.
To support _field_changed? method renamed from field_changed?