From c251e7fd3f966e1e2cd84a3abc250d1cb95ff8fe Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 20 Nov 2015 21:55:32 -0500 Subject: [PATCH] Better error when linking to username that doesn't exist --- app/controllers/users_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 70fc235d3..a081101e5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,7 +17,11 @@ class UsersController < ApplicationController def index if params[:name].present? @user = User.find_by_name(params[:name]) - redirect_to user_path(@user) + if @user.nil? + raise "No user found with name: #{params[:name]}" + else + redirect_to user_path(@user) + end else @users = User.search(params[:search]).order("users.id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@users) do |format|