Hello, I just want to check in the code if some template is present in
views or not. In rails 2.3 I did this with following code -
view_paths.find_template(template_path, default_template_format). But
in rails3 it doesn't work and when I try to use view_paths.find with
some parameters, I get strange error:
NoMethodError Exception: You have a nil object when you didn't expect
You might have expected an instance of Array.
The error occurred while evaluating nil.map
Can you help me with function to check if view exists in rails3?
I had been checking through the view path code this past week -- for a
different reason: I don't want any checking in the view paths at all.
I am still don't have a clear picture of the entire dispatch stack,
but as far as I can tell, the default responder attempts to render
something, view_paths gets checked, then it throws
ActionView::MissingTemplate ... api_behavior (such as rendering json /
xml) gets called as a result of rescuing from that exception. Assuming
you are checking for the view within the dispatch and depending on
what you want to do, you can handle the exception yourself (if it
isn't found) or extend the default responder.