Hi folks,
I have a component on my site called RelatedController. I intend to
put some links and content related with the current page (controller
and action). What I want to do is for the time being is
render :partial "#{@current_controller}_#{@current_action}"
Then in the component template root I have templates like
_products_index _products_cart etc. I have decided to put this into a
component because over the time I''ll be integrating more logic into
the component but for now all I want is to render a template if it
exists.
Can anybody recomend how to test the existence of a template and
render if only it exists?
The error I get is
ActionView::ActionViewError in Sidebar/related#display_box
No rhtml, rxml, or delegate template found for sidebar/related/
_products_index
<%= render :partial =>
"#{@current_controller}_#{@current_action}" %>
I was thinking to catch the exception but then I would have to write
this in the view code of the component, which I don''t want to do. On
the other hand if I render the partial template to a string, than I''d
be limiting myself to a specific implementation. In a few days, I''ll
be coding different related items logic.
I''m just wondering if there is anything like
render :partial => "sometemplate" if FileTest.exists? <a neat
way to
access the template''s full path>
Thanks in advance for any tips on design would be most welcome.
Regards,
Oyku.