1000 Words


Collapse Content

Now that your app can check for valid words, you just need to get a list of valid words. There are various lists online of the 1000 most common words, but you'll also want to accept alternate forms of each word. Luckily, we have a list prepared a list for you:

http://simple-word-blog.herokuapp.com/all_words.txt

Download that list to your app/db folder. Then add the following code to db/seeds.rb

words = File.read('db/all_words.txt') #1
words.split.each do |word|            #2
    Word.create(word: word)           #3
end

This code does the following:

  1. Reads the file to a Ruby string.
  2. Splits the file by its spaces and goes through each word.
  3. Creates a Word record for each word in the file.

Now run rake db:seed to setup your database. Your blogging platform is now ready for action!

Contact Us
Sign in or email us at [email protected]