Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Pages with children now preview correctly
won't crash on change of page type for existing pages
  • Loading branch information
cradle committed Oct 17, 2008
1 parent f80bbea commit 8aa1621
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/controllers/preview_controller.rb
Expand Up @@ -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
Expand All @@ -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.