Yeah. After creating the table, you can call up the state model and start filling out the table.
class LoadStates < ActiveRecord::Migration def self.up states = ['state1','state2','state2'] for state in states State.create(:name=>state) end end def self.down State.delete_all end end
If you want more imagination, I would use an activerecord-import gem to do a volume insert. This is also a good approach if you have hundreds or thousands of records to import.
def self.up states = ['state1','state2','state2'] states_for_import = [] for state in states states_for_import << State.new(:name=>state) end State.import states_for_import end
source share