Skip to content

Instantly share code, notes, and snippets.

@bjensen
Created May 25, 2010 15:52
Show Gist options
  • Save bjensen/413297 to your computer and use it in GitHub Desktop.
Save bjensen/413297 to your computer and use it in GitHub Desktop.
<h3>Filter Tickets</h3>
<ul id="filter-links">
<%= ticket_filter_links 'open', @current_user.id -%>
<%= ticket_filter_links 'closed', @current_user.id -%>
<%= ticket_filter_links 'open' -%>
<%= ticket_filter_links 'closed' -%>
</ul>
def ticket_filter_links(status_name, user_id=nil)
if user_id.nil?
if status_name.downcase == 'closed'
content_tag(:li, link_to("All Closed Tickets", tickets_path + "?search[status_id_equals]=#{@closed_status.id}"))
else
content_tag(:li, link_to("All Active Tickets", tickets_path))
end
else
if status_name.downcase == 'closed'
content_tag(:li, link_to("My Closed Tickets", tickets_path + "?search[status_id_equals]=#{@closed_status.id}&search[owned_by_equals]=#{user_id}"))
else
content_tag(:li, link_to("My Open Tickets", tickets_path + "?search[status_id_equals]=#{@open_status.id}&search[owned_by_equals]=#{user_id}"))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment