Permalink
Browse files

Split one liner up in to two methods

  • Loading branch information...
1 parent f40f646 commit 158a7f021793530f9e785480536a4a9db333f43d Kris Leech committed Feb 24, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 app/controllers/documents_controller.rb
@@ -7,14 +7,14 @@ def index
end
def show
- path = params[:permalink].present? ? '/' + params[:permalink] : request.path == '/' ? '/home' : request.path
+ path = permalink_path || home_path || request.path
@document = Document.public.find_by_permalink!(path)
prepare_view_environment
render locate_template(@document)
end
private
-
+
def prepare_view_environment
# e.g @blog
instance_variable_set("@#{@document.node_name}", @document)
@@ -66,4 +66,12 @@ def locate_template(document)
end
raise NoTemplateFound
end
+
+ def permalink_path
+ params[:permalink].present? ? '/' + params[:permalink] : nil
+ end
+
+ def home_path
+ request.path == '/' ? '/home' : nil
+ end
end

0 comments on commit 158a7f0

Please sign in to comment.