Class: Lokka::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/lokka.rb

Instance Method Summary collapse

Constructor Details

#initializeDatabase

Returns a new instance of Database.



42
43
44
# File 'lib/lokka.rb', line 42

def initialize
  @@models = [Site, Option, User, Entry, Category, Comment, Tag, Tagging]
end

Instance Method Details

#createObject



46
47
48
49
50
# File 'lib/lokka.rb', line 46

def create
  puts 'Creating Database...'
  @@models.each {|m| m.auto_migrate! }
  self
end

#setupObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/lokka.rb', line 52

def setup
  puts 'Initializing Database...'
  User.create(
    :name => 'test',
    :password => 'test',
    :password_confirmation => 'test')
  Site.create(
    :title => 'Test Site',
    :description => 'description...',
    :theme => 'jarvi')
  Post.create(
    :user_id => 1,
    :title => "Test Post",
    :body => "<p>Wellcome to Lokka!</p>\n<p><a href=\"/admin/\">Admin login</a> (user / password : test / test)</p>")
  self
end