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

Commit

Permalink
minimize code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
cradle committed Oct 17, 2008
1 parent 8aa1621 commit 1728558
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/controllers/preview_controller.rb
Expand Up @@ -2,11 +2,7 @@ class PreviewController < ApplicationController
skip_before_filter :verify_authenticity_token
layout false
def show
page = get_page
params.fetch('part', []).each do |i, attrs|
page.parts << PagePart.new(attrs)
end
page.process(request,response)
construct_page.process(request,response)
@performed_render = true
end

Expand All @@ -20,14 +16,17 @@ def page_class
end
end

def get_page
def construct_page
if request.referer =~ %r{/admin/pages/(\d+)/child/new}
page = page_class.new(params['page'])
page.parent = Page.find($1)
elsif request.referer =~ %r{/admin/pages/edit/(\d+)}
page = Page.find($1)
page.attributes = params['page']
end
params.fetch('part', []).each do |i, attrs|
page.parts << PagePart.new(attrs)
end
return page
end
end

0 comments on commit 1728558

Please sign in to comment.