Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pages with children now preview correctly

won't crash on change of page type for existing pages
  • Loading branch information...
commit 8aa162105eae09005caab180704b7e6d4ffb5a73 1 parent f80bbea
@cradle cradle authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 app/controllers/preview_controller.rb
View
14 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
Please sign in to comment.
Something went wrong with that request. Please try again.