'Update all existing records with computed value of another field in Rails
class UpdateBrowserLanguageInInsightsVisits < ActiveRecord::Migration[6.1]
def change
Insights::Visit.update_all("browser_language = Iso639[context[`browser`][`language`]]&.name")
end
end
I want to update all existing records with computed value of another json field called "context"
How do I get reference to another field in table inside update_all?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|