Skip to content

Instantly share code, notes, and snippets.

@pedrozath
Last active March 27, 2018 11:43
Show Gist options
  • Select an option

  • Save pedrozath/a8022a9d33dfd1eb9aecc563689412ef to your computer and use it in GitHub Desktop.

Select an option

Save pedrozath/a8022a9d33dfd1eb9aecc563689412ef to your computer and use it in GitHub Desktop.
TruckVisit.all.each do |tv|
t = tv.in_reefer_temperature
next if t.blank?
# we set the temperature to float if first character is a digit
# else we set it to nil
tv.update_column(:in_reefer_temperature, (t[0] =~ /\d/ ? t.to_f : nil))
end
@marcelinol
Copy link
Copy Markdown

I get this error: LocalJumpError: unexpected return
on line 3 it should be next if t.blank?

@pedrozath
Copy link
Copy Markdown
Author

yes, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment