Skip to content

Commit e9a26eb

Browse files
committed
fix filtering by tag
1 parent c544f22 commit e9a26eb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/controllers/content_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def index
4040
page_type: @content_type_class.name,
4141
page_id: @content.pluck(:id)
4242
).order(:tag)
43-
if params.key?(:tag)
44-
@filtered_page_tags = @page_tags.where(slug: params[:tag])
43+
if params.key?(:slug)
44+
@filtered_page_tags = @page_tags.where(slug: params[:slug])
4545
@content.select! { |content| @filtered_page_tags.pluck(:page_id).include?(content.id) }
4646
end
4747
@page_tags = @page_tags.uniq(&:tag)

app/views/content/components/_list_filter_bar.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</a>
6161
<ul id='tag-filter-dropdown' class='dropdown-content'>
6262
<li>
63-
<%= link_to params.permit(:tag, :favorite_only).merge({ tag: nil }), class: "#{content_type.text_color}" do %>
63+
<%= link_to params.permit(:tag, :favorite_only).merge({ slug: nil }), class: content_type.text_color do %>
6464
<i class="material-icons"><%= PageTag.icon %></i>
6565
All <%= content_type.name.downcase.pluralize %>
6666
<% end %>
@@ -69,7 +69,7 @@
6969
<% if @page_tags %>
7070
<% @page_tags.each do |page_tag| %>
7171
<li>
72-
<%= link_to params.permit(:tag, :favorite_only).merge({ tag: PageTagService.slug_for(page_tag.tag) }), class: "#{content_type.text_color}" do %>
72+
<%= link_to params.permit(:tag, :favorite_only).merge({ slug: PageTagService.slug_for(page_tag.tag) }), class: content_type.text_color do %>
7373
<i class="material-icons"><%= PageTag.icon %></i>
7474
<small class="grey-text">tagged</small>
7575
<%= page_tag.tag %>

0 commit comments

Comments
 (0)