I have a helper that renders a partial. The partial may or may not
exist. If it does not exist then a different partial is rendered
instead. Like this:
def render_my_partial my_partial
begin
render :partial => “folder1/#{my_partial}”
rescue
render :partial => “folder2/#{my_partial}”
end
end
This in itself works fine. One of my layouts uses this helper to display
one of two partials:
<%=render_my_partial ‘display_area’%>
If one of these partials uses another helper that itself uses the above
helper to render one of two other partials:
def info_panel
render_my_partial ‘info_panel’
end
This fails.
However, if I replicate the above code directly in the second helper
function then it works.
def info_panel
begin
render :partial => “folder1/info_panel”
rescue
render :partial => “folder2/info_panel”
end
end
I don’t understand this. I could leave it with duplicated code but it
isn’t very DRY and I’d like to understand why this does not work as I
expect. Can anyone help explain this to me?
Thanks in advance!