Skip to content

Instantly share code, notes, and snippets.

@tubbo
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/11408351 to your computer and use it in GitHub Desktop.
Save tubbo/11408351 to your computer and use it in GitHub Desktop.
class CreateWords < ActiveRecord::Migration
def change
create_table :words do |t|
t.string :text
t.integer :frequency
t.integer :mistakes
t.timestamps
end
end
end
class Word < ActiveRecord::Base
#attr_accessor :text, :frequency, :mistakes
end
task :words => :environment do
File.open("all_words.txt").each do |w|
word = Word.create(text: w.chop, frequency: 0, mistakes: 0)
unless word.valid?
puts word.errors.full_messages.join(', ')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment