require 'rubygems' require_gem 'activerecord' ActiveRecord::Base.establish_connection(:adapter=>"mysql", :database => "", :user=> "root") ActiveRecord::Base.connection.execute("drop database if exists cecs524") ActiveRecord::Base.connection.execute("create database cecs524") ActiveRecord::Base.connection.execute("use cecs524") ActiveRecord::Base.connection.execute("drop table if exists words") ActiveRecord::Base.connection.execute("create table words ( id INT not null auto_increment, spelling CHAR(20), primary key (id))") class Word < ActiveRecord::Base end puts puts "Add Animal, Bank and Carriage to the list of words." aWord1 = Word.new aWord1.spelling = "Animal" aWord1.save aWord2 = Word.new aWord2.spelling = "Bank" aWord2.save aWord3 = Word.new aWord3.spelling = "Carriage" aWord3.save puts puts "Find and print the first word." puts Word.find(:first).spelling puts puts "Print all the words." queryresults = Word.find(:all) queryresults.each do |row| print row.spelling, "\n" end puts puts "Delete Bank from the list of words." Word.delete_all("spelling = 'Bank'") puts puts "Print the list of words again." queryresults = Word.find(:all) queryresults.each do |row| print row.spelling, "\n" end gets