Sha256: a6d593dfa5f940f6184889143ee38be130aaf6ad7333f2d2e4469ac327b3b553
Contents?: true
Size: 668 Bytes
Versions: 9
Compression:
Stored size: 668 Bytes
Contents
require 'sequel' Sequel::Model.plugin(:schema) DB = Sequel.connect("sqlite:///#{__DIR__}/../blog.db") class Entry < Sequel::Model(:entry) set_schema do primary_key :id time :created time :updated text :title text :content end def self.add(title, content) create :title => title, :content => content, :created => Time.now, :updated => Time.now end def update(title = title, content = content) self.title, self.content, self.updated = title, content, Time.now save end end Entry.create_table! unless Entry.table_exists? if Entry.empty? Entry.add 'Blog created', 'Exciting news today, this blog was created' end
Version data entries
9 entries across 9 versions & 2 rubygems