I am trying to run this data migration.
class StateLabel < ActiveRecord::Migration
def self.up
states = {one: 'ONE', two: 'TWO', three: 'THREE'}
Wms.all.each do |w|
states.each do |k, v|
StateLabel.create(wms_id: w.id, state: k.to_s, label: v)
end
end
end
def self.down
raise IrreversibleMigration
end
end
I'm getting this error:
== StateLabel: migrating ================================================ -- create({:wms_id=>1, :state=>"One", :label=>"ONE"}) rake aborted! An error has occurred, this and all later migrations canceled:
PG::SyntaxError: ERROR: syntax error at or near "{" LINE 1: {:wms_id=>1, :state=>"One", :label=>"ONE...
I can't see any syntax errors. I can run that code in the console just fine.
Any idea what's going on?
Aucun commentaire:
Enregistrer un commentaire