Permalink
Browse files

Fix filter by section

  • Loading branch information...
1 parent 6ff43cc commit 79188219402041805cbc458d4ad1cb42b1b99a97 Mazz Mosley committed Oct 25, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 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

0 comments on commit 7918821

Please sign in to comment.