Created
May 28, 2011 23:02
-
-
Save robinhoode/997322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def controller_header_exists? | |
app_views = File.join(Rails.root, "app", "views") | |
controller_header = File.join(app_views, "#{controller_name}/_header.html.erb") | |
File.exists? controller_header | |
end | |
def controller_header_partial | |
"#{controller_name}/header" | |
end | |
# Use this in your layout/application.html.erb | |
# <%= include_controller_header %> | |
def include_controller_header | |
if controller_header_exists? | |
render :partial => controller_header_partial | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment