Created
June 17, 2015 06:17
-
-
Save dangjlin/510b29aab07bf77fd099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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