I have a simple partial for my footer that looks like this:
<footer class="footer">
<nav>
<ul>
<li><%= link_to "Download History", report_histories_path(format: "csv") %>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "About", about_path %></li>
</ul>
</nav>
</footer>
The first link allows the user to download some data used to power reports as a CSV, but I only want this to link to appear if the reports_controller is used to render the partial.
I've tried using
<% if params[:reports] %>
<li><%= link_to "Download History", report_histories_path(format: "csv") %>
<% end %>
as well as
<% if current_page?(url_for(:controller => 'reports')) %>
<li><%= link_to "Download History", report_histories_path(format: "csv") %>
<% end %>
but neither show the link.
You can use params[:controller] for that. Also, params[:action] will contain current action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With