Created
December 6, 2010 18:20
-
-
Save jocap/730682 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 "dm-core" | |
require "dm-migrations" | |
# Configure DataMapper | |
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://database.db") | |
# model Article | |
class Article | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, Text | |
property :text, Text | |
property :author, String | |
property :permalink, Text | |
property :created_at, DateTime | |
end | |
# Update database | |
DataMapper.auto_upgrade! | |
class String | |
# Fix DataMapper's weird space bug | |
def rm_ln | |
self.gsub(/\n\n|\n/, "\r") | |
end | |
def rm_ln! | |
self.gsub(/\n\n|\n/, "") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment