app/controllers/services_controller.rb
# find_by_id wont error out and is just nil if it cant find it
find_by_id wont error out and is just nil if it cant find it
find_by_id wont error out and is just nil if it cant find it
def show
    if params[:ai_id]
      @ai = Ai.find_by(id: params[:ai_id])
      @services = @ai.services.find_by(id: params[:id])
      if @service.nil?
        redirect_to ai_services_path(@ai), alert:"Service not found"
      end
    else
      set_service
    end
  end
def show if params [ :ai_id ] @ai = Ai . find_by ( id : params [ :ai_id ] ) @services = @ai . services . find_by ( id : params [ :id ] ) if @service . nil? redirect_to ai_services_path ( @ai ) , alert : "Service not found" end else set_service end end
find_by_id wont error out and is just nil if it cant find it
find_by_id wont error out and is just nil if it cant find it