0

A rails controller method is attempting to pass object changes

      if @union.update(union_params)
puts '||'
puts @union.changed
puts @union.changes
        @union.update_with_log(union_params, current_user.id)

However, when this runs the console registers an empty hash for the changes and does not even handle the changed verb.

||
{}

The changes verb acts as expectedwhen testing in the console with a variable invoked. However, the application's operating context is with tranlsatable variables with handling through the mobility gem.

In practice the console registers edits the following manner:

Mobility::Backends::ActiveRecord::KeyValue::TextTranslation Update (0.4ms)  UPDATE "mobility_text_translations" SET "value" = $1, "updated_at" = $2 WHERE "mobility_text_translations"."id" = $3 [...]

Why is this behaviour different with mobility & an instance variable?

Jerome
  • 5,583
  • 3
  • 33
  • 76

1 Answers1

0

The method that needs to be invoked is previous_changes as indicated in the documentation towards the end of the Dirty tracking section and not changes (the documentation is not explicit on the latter point at time of writing).

Jerome
  • 5,583
  • 3
  • 33
  • 76