-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 7.0.5
-
Component/s: Attributes
-
None
-
Environment:Linux, Rails 6.0.2.1
-
Minor Change
As per my comments below I believe the work that should be done in this ticket is actually opposite of the requested changes. This ticket originally was to add the changing of the HABTM association to the changes hash, however I believe the correct way to proceed is to remove that change from the changed_attributes hash. (See my comments below for a longer discussion of why that is)
Original ticket:
tether-it(test)> user.timelines = [t1, t2]
tether-it(test)> user.changed?
=> false
tether-it(test)> user.changes
=> {}
tether-it(test)> user.changed_attributes
=> {"timeline_ids"=>[BSON::ObjectId('5e481d75e23a26c32d8cb4fe'), BSON::ObjectId('5e481d75e23a26c32d8cb4ff')]}
The expected results would be for .changes to show: "timeline_ids" => [[], [t1.id, t2.id]]
The code in the model is:
has_and_belongs_to_many :timelines,
inverse_of: nil, validate: false, index: true
validate :assigned_timelines, on: :update, if: :timeline_ids_changed?
Any ideas?