Permalink
Browse files

minimize code a bit

  • Loading branch information...
1 parent 8aa1621 commit 1728558bd274f8eb0d6dedf5da9fe5b3d4c44c32 @cradle cradle committed Oct 17, 2008
Showing with 5 additions and 6 deletions.
  1. +5 −6 app/controllers/preview_controller.rb
@@ -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
@@ -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.