Permalink
Browse files

Fix up the default body thing

  • Loading branch information...
1 parent 925c7ff commit d8728051010583e3c3aea0469d4f36054f605d9b @jacquescrocker jacquescrocker committed Aug 1, 2010
Showing with 5 additions and 2 deletions.
  1. +1 −1 app/models/extensions/page/parts.rb
  2. +3 −0 app/models/page.rb
  3. +1 −1 spec/models/page_spec.rb
@@ -8,7 +8,7 @@ module Parts
included do
before_validation do |p|
if p.parts.empty?
- p.parts << PagePart.build_body_part(p.try(:body))
+ p.parts << PagePart.build_body_part(p.respond_to?(:body) ? p.body : nil)
end
end
end
View
@@ -15,6 +15,9 @@ class Page
field :published, :type => Boolean, :default => false
field :cache_strategy, :default => 'none'
+ # allows newly pages to have a default body
+ attr_accessor :body
+
## associations ##
referenced_in :site
referenced_in :layout
@@ -354,7 +354,7 @@
end
it "should render the passed in body attribute of the page" do
- @page.render(Liquid::Context.new).should == "PageBody"
+ @page.render(Liquid::Context.new).should == "Page Body"
end
end
end

0 comments on commit d872805

Please sign in to comment.