Skip to content
Browse files

Display the user's name in the title.

Also fixed a bug where a missing or incorrect user ID would cause an
uncaught exception. Now it 404s.
  • Loading branch information...
1 parent 4ca453c commit b5c664e307218053ecfcc41546c5c07fabc4fa8a @fatbusinessman fatbusinessman committed May 28, 2012
Showing with 7 additions and 6 deletions.
  1. +6 −5 app/controllers/admin/user_search_controller.rb
  2. +1 −1 app/views/admin/user_search/index.html.erb
View
11 app/controllers/admin/user_search_controller.rb
@@ -3,21 +3,22 @@ class Admin::UserSearchController < Admin::BaseController
def index
@user_filter = params[:user_filter] || current_user.uid
- user = params[:user_filter] ? User.find_by_uid(@user_filter) : current_user
+ @user = params[:user_filter] ? User.find_by_uid(@user_filter) : current_user
+ raise ActionController::RoutingError.new('Not Found') unless @user
# Including recipient_id on actions will include anything that has been
# assigned to the user we're looking at, but include the check anyway to
# account for manual assignments
editions = WholeEdition.any_of(
- {'assigned_to_id' => user.id},
- {'actions.requester_id' => user.id},
- {'actions.recipient_id' => user.id}
+ {'assigned_to_id' => @user.id},
+ {'actions.requester_id' => @user.id},
+ {'actions.recipient_id' => @user.id}
).excludes(state: 'archived').order_by(last_updated_at: -1)
# Need separate assignments here because Kaminari won't preserve pagination
# info across a map, and we don't want to load every edition and paginate
# the resulting array
@page_info = editions.page(params[:page]).per(20)
- @editions = @page_info.map { |e| UserSearchEditionDecorator.new e, user }
+ @editions = @page_info.map { |e| UserSearchEditionDecorator.new e, @user }
end
end
View
2 app/views/admin/user_search/index.html.erb
@@ -2,7 +2,7 @@
<div class="span12">
<div class="page-header">
- <h1>User search</h1>
+ <h1>User search for <%= @user %></h1>
</div>
<div class="row-fluid">

0 comments on commit b5c664e

Please sign in to comment.
Something went wrong with that request. Please try again.