If terms are removed show all results for current status

This commit is contained in:
Adam Leonard 2011-10-25 20:15:11 -04:00
parent 0955863489
commit 92f6de0370
3 changed files with 62 additions and 21 deletions

View file

@ -79,8 +79,17 @@ class IssuesController < ApplicationController
end
def search
@project = Project.find(params['project'])
@issues = @project.issues.where("title LIKE ? OR content LIKE ?", "%#{params['terms']}%", "%#{params['terms']}%")
terms = params['terms']
@project = Project.find(params['project'])
@issues = case params[:status].to_i
when 1 then @project.issues
when 2 then @project.issues.closed
when 3 then @project.issues.opened.assigned(current_user)
else @project.issues.opened
end
@issues = @issues.where("title LIKE ? OR content LIKE ?", "%#{terms}%", "%#{terms}%") unless terms.blank?
render :partial => 'issues'
end