Permalink
Browse files

Pages with children now preview correctly

won't crash on change of page type for existing pages
  • Loading branch information...
1 parent f80bbea commit 8aa162105eae09005caab180704b7e6d4ffb5a73 @cradle cradle committed Oct 17, 2008
Showing with 7 additions and 7 deletions.
  1. +7 −7 app/controllers/preview_controller.rb
@@ -2,8 +2,7 @@ class PreviewController < ApplicationController
skip_before_filter :verify_authenticity_token
layout false
def show
- page = page_class.new(params['page'])
- page.parent = parent
+ page = get_page
params.fetch('part', []).each do |i, attrs|
page.parts << PagePart.new(attrs)
end
@@ -21,13 +20,14 @@ def page_class
end
end
- def parent
+ def get_page
if request.referer =~ %r{/admin/pages/(\d+)/child/new}
- Page.find($1)
+ page = page_class.new(params['page'])
+ page.parent = Page.find($1)
elsif request.referer =~ %r{/admin/pages/edit/(\d+)}
- Page.find($1).parent
- else
- nil
+ page = Page.find($1)
+ page.attributes = params['page']
end
+ return page
end
end

0 comments on commit 8aa1621

Please sign in to comment.