Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some fixes I made while working on a CRUD front-end, pulled out to co…

…mmit early. Will have to refactor entire Post and PostRevision model before I can complete the CRUD front-end.
  • Loading branch information...
commit 47e2bc6db35d1c00993ab80595065aefe0c5f198 1 parent b2d992a
@ELLIOTTCABLE authored
View
3  app/models/post.rb
@@ -16,8 +16,9 @@ class Post < DataMapper::Base
# Alias up some more sensible revisions
alias :revisions :post_revisions; alias :revisions= :post_revisions=
- def initialize(*args); super
+ def initialize(*args)
revisions << self.class.revision.new
+ super
end
def content=(content); revisions.last.content=(content); end
View
2  app/models/post_revision.rb
@@ -4,6 +4,7 @@ class PostRevision < DataMapper::Base
belongs_to :post
validates_presence_of :post
+ validates_presence_of :content
def content=(content)
if new_record?
@@ -11,6 +12,7 @@ def content=(content)
else
r = self.class.new(:content => content)
post.revisions << r
+ content # return
end
end
View
4 config/init.rb
@@ -41,6 +41,8 @@
# use_test :test_unit
use_test :rspec
+Merb.logger.auto_flush = true
+
### Add your other dependencies here
# These are some examples of how you might specify dependencies.
@@ -52,6 +54,8 @@
# dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
dependencies 'datamapper'
+dependency 'merb-action-args'
+dependency 'merb_helpers'
Merb::BootLoader.after_app_loads do
### Add dependencies here that must load after the application loads:
Please sign in to comment.
Something went wrong with that request. Please try again.