Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix filter by section

  • Loading branch information...
commit 79188219402041805cbc458d4ad1cb42b1b99a97 1 parent 6ff43cc
Mazz Mosley authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 app/controllers/artefacts_controller.rb
View
9 app/controllers/artefacts_controller.rb
@@ -6,11 +6,14 @@ class ArtefactsController < ApplicationController
respond_to :html, :json
def index
- @artefacts = Artefact.order_by([[:name, :asc]])
-
@section = params[:section] || "all"
if @section != "all"
- @artefacts = @artefacts.where(tag_ids: params[:section])
+ tags = Tag.where(tag_type: "section", parent_id: @section)
+ tag_ids = tags.collect {|t| t.tag_id}
+ tag_ids << @section
+ @artefacts = Artefact.any_in(tag_ids: tag_ids).order_by([[:name, :asc]])
+ else
+ @artefacts = Artefact.order_by([[:name, :asc]])
end
respond_with @artefacts, @tag_collection
end
Please sign in to comment.
Something went wrong with that request. Please try again.