Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
Blogs Made Simple, with invisible assurances of setup. Original with …
Browse files Browse the repository at this point in the history
…pains of planning for winter roosting moved to the side.
  • Loading branch information
busbey committed Mar 24, 2010
1 parent e24828f commit 92820d6
Show file tree
Hide file tree
Showing 2 changed files with 388 additions and 33 deletions.
51 changes: 18 additions & 33 deletions examples/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ module Blog
include Camping::Session

module Models
class Post < Base
class Post < Base do |t|
t.integer :user_id, :null => false
t.string :title, :limit => 255
t.text :body, :html_body
t.timestamps
end
belongs_to :user

before_save do |record|
Expand All @@ -22,35 +27,19 @@ class Post < Base
end
end

class Comment < Base; belongs_to :user; end
class User < Base; end

class BasicFields < V 1.1
def self.up
create_table :blog_posts, :force => true do |t|
t.integer :user_id, :null => false
t.string :title, :limit => 255
t.text :body, :html_body
t.timestamps
end
create_table :blog_users, :force => true do |t|
t.string :username, :password
end
create_table :blog_comments, :force => true do |t|
t.integer :post_id, :null => false
t.string :username
t.text :body, :html_body
t.timestamps
end
User.create :username => 'admin', :password => 'camping'
end

def self.down
drop_table :blog_posts
drop_table :blog_users
drop_table :blog_comments
class Comment < Base do |t|
t.integer :post_id, :null => false
t.string :username
t.text :body, :html_body
t.timestamps
end
belongs_to :user
end
class User < Base do |t|
t.string :username, :password
t.create :username => 'admin', :password => 'camping'
end
end
end
end

module Controllers
Expand Down Expand Up @@ -261,10 +250,6 @@ def _form(post, opts)
end
end

def Blog.create
Blog::Models.create_schema :assume => (Blog::Models::Post.table_exists? ? 1.0 : 0.0)
end

__END__
* {
margin: 0;
Expand Down

0 comments on commit 92820d6

Please sign in to comment.