aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2010-08-09 16:47:56 +1200
committerPhilip Arndt <parndt@gmail.com>2010-08-09 16:47:56 +1200
commit837ea01a34a7dddeefe8086b2c6fc28e9a14616c (patch)
tree26c3c55c9026518de8b0626001cc55116bc5c87e /app/models
parent9a8b95e9aa71529d7b4173a3afce49b199a60615 (diff)
downloadrefinerycms-blog-837ea01a34a7dddeefe8086b2c6fc28e9a14616c.tar.gz
refinerycms-blog-837ea01a34a7dddeefe8086b2c6fc28e9a14616c.tar.bz2
refinerycms-blog-837ea01a34a7dddeefe8086b2c6fc28e9a14616c.zip
Initial commit - you can create, edit and delete a blog post and it respects the fact that it is draft or not.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/blog_category.rb10
-rw-r--r--app/models/blog_comment.rb8
-rw-r--r--app/models/blog_post.rb14
3 files changed, 32 insertions, 0 deletions
diff --git a/app/models/blog_category.rb b/app/models/blog_category.rb
new file mode 100644
index 0000000..9060d11
--- /dev/null
+++ b/app/models/blog_category.rb
@@ -0,0 +1,10 @@
+class BlogCategory < ActiveRecord::Base
+
+ acts_as_indexed :fields => [:title]
+
+ validates_presence_of :title
+ validates_uniqueness_of :title
+
+ has_friendly_id :title, :use_slug => true
+
+end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
new file mode 100644
index 0000000..4398475
--- /dev/null
+++ b/app/models/blog_comment.rb
@@ -0,0 +1,8 @@
+class BlogPost < ActiveRecord::Base
+
+ acts_as_indexed :fields => [:name, :email, :body]
+
+ validates_presence_of :title
+ validates_uniqueness_of :title
+
+end
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb
new file mode 100644
index 0000000..481b8cb
--- /dev/null
+++ b/app/models/blog_post.rb
@@ -0,0 +1,14 @@
+class BlogPost < ActiveRecord::Base
+
+ acts_as_indexed :fields => [:title, :body]
+
+ validates_presence_of :title
+ validates_uniqueness_of :title
+
+ has_friendly_id :title, :use_slug => true
+
+ default_scope :order => "created_at DESC"
+
+ named_scope :live, :conditions => {:draft => false}
+
+end