Better error when linking to username that doesn't exist

This commit is contained in:
Toks
2015-11-20 21:55:32 -05:00
parent 8473cfa109
commit c251e7fd3f

View File

@@ -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|