Updated backfill instructions [skip ci]
Andrew
committed May 13, 2018
commit 2dfe7f36d4d7a3aa1394aaba3f4501e5acb8ccb9
Showing 1
changed file with
12 additions
and 2 deletions
README.md
+12
-2
| @@ | @@ -584,10 +584,20 @@ Backfill existing records with: |
| ```ruby | |
| Ahoy::Visit.find_each do |visit| | |
| client = DeviceDetector.new(visit.user_agent) | |
| + | device_type = |
| + | case client.device_type |
| + | when "smartphone" |
| + | "Mobile" |
| + | when "tv" |
| + | "TV" |
| + | else |
| + | client.device_type.try(:titleize) |
| + | end |
| + | |
| visit.browser = client.name | |
| visit.os = client.os_name | |
| - | visit.device_type = client.device_type.try(:titleize) |
| - | visit.save(validate: false) |
| + | visit.device_type = device_type |
| + | visit.save(validate: false) if visit.changed? |
| end | |
| ``` | |