Skip to content

Instantly share code, notes, and snippets.

@dangjlin
Created June 17, 2015 06:17
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 dangjlin/510b29aab07bf77fd099 to your computer and use it in GitHub Desktop.
Save dangjlin/510b29aab07bf77fd099 to your computer and use it in GitHub Desktop.
require 'active_record'
ActiveRecord::Base.establish_connection :adapter => "sqlite3",
:database => "dbfile"
# Initialize the database schema
ActiveRecord::Base.connection.create_table :ducks do |t|
t.string :name
end
class Duck < ActiveRecord::Base
validate do
errors.add(:base, "Illegal duck name.") unless name[0] == 'D'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment