Added search for issues

This commit is contained in:
Shrey 2015-06-10 12:34:26 +05:30 committed by Matt Amos
parent c7bc13668b
commit 0a3dd82c47
4 changed files with 31 additions and 1 deletions

View file

@ -7,7 +7,22 @@ class IssuesController < ApplicationController
before_action :find_issue, only: [:show, :resolve, :reopen, :ignore]
def index
@issues = Issue.all.order(:status)
if params[:search_by_user].present?
@user = User.find_by_display_name(params[:search_by_user])
if @user.present?
@issues = Issue.where(reported_user_id: @user.id).order(:status)
else
@issues = Issue.all.order(:status)
redirect_to issues_path, notice: t('issues.index.search.user_not_found')
end
if @user.present? and not @issues.present?
@issues = Issue.all.order(:status)
redirect_to issues_path, notice: t('issues.index.search.issues_not_found')
end
else
@issues = Issue.all.order(:status)
end
end
def show