Does template exist?
An instance of the class ActionView::LookupContext::ViewPaths
is available as lookup_context
in a rails view.
If you need to dynamically construct partial paths and know that sometimes the partial may not exist, you can use the lookup_context
method exists?
to determine if the partial exists.
lookup_context.exists?(dynamic_path, [], true)
The third argument is partial
, the second argument is prefixes
.