Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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
ELLIOTTCABLE committed Mar 5, 2008
1 parent b2d992a commit 47e2bc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/post.rb
Expand Up @@ -16,8 +16,9 @@ class Post < DataMapper::Base
# Alias up some more sensible revisions # Alias up some more sensible revisions
alias :revisions :post_revisions; alias :revisions= :post_revisions= alias :revisions :post_revisions; alias :revisions= :post_revisions=


def initialize(*args); super def initialize(*args)
revisions << self.class.revision.new revisions << self.class.revision.new
super
end end


def content=(content); revisions.last.content=(content); end def content=(content); revisions.last.content=(content); end
Expand Down
2 changes: 2 additions & 0 deletions app/models/post_revision.rb
Expand Up @@ -4,13 +4,15 @@ class PostRevision < DataMapper::Base


belongs_to :post belongs_to :post
validates_presence_of :post validates_presence_of :post
validates_presence_of :content


def content=(content) def content=(content)
if new_record? if new_record?
@content = content @content = content
else else
r = self.class.new(:content => content) r = self.class.new(:content => content)
post.revisions << r post.revisions << r
content # return
end end
end end


Expand Down
4 changes: 4 additions & 0 deletions config/init.rb
Expand Up @@ -41,6 +41,8 @@
# use_test :test_unit # use_test :test_unit
use_test :rspec use_test :rspec


Merb.logger.auto_flush = true

### Add your other dependencies here ### Add your other dependencies here


# These are some examples of how you might specify dependencies. # These are some examples of how you might specify dependencies.
Expand All @@ -52,6 +54,8 @@
# dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0" # dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
dependencies 'datamapper' dependencies 'datamapper'


dependency 'merb-action-args'
dependency 'merb_helpers'


Merb::BootLoader.after_app_loads do Merb::BootLoader.after_app_loads do
### Add dependencies here that must load after the application loads: ### Add dependencies here that must load after the application loads:
Expand Down

0 comments on commit 47e2bc6

Please sign in to comment.