Hey folks,
I’ve run into the need to test for the existence of template files in
several Rails apps I’ve worked on. Particularly in circumstances
where I’m rendering a partial, and use a different partial template
for different sub-classes of a model object. When doing so, I often
test to make sure the template file exists first, and simply skip
that item if no template exists.
So right now I rely on a cludgy and annoying:
File.exist?( File.join( ActionController::Base.template_root,
“layouts”, “some_subdir”, “_%s.rhtml” % method_param ))
Anyone have a better, more elegant (and less hackish) method of doing
this?
-Justin Wienckowski
[email protected]