require_dependency "jobshop/application_controller" module Jobshop class Teams::LookupsController < ApplicationController skip_before_action :authenticate_user! def show @lookup = Jobshop::User.new end def create email_addresses = params[:user][:email].split(",").map(&:strip).take(5) @lookup = Jobshop::User .where(email: email_addresses) .joins(:team) .select("jobshop_users.id AS id", "email", "jobshop_teams.name AS team_name") .group_by(&:email) @lookup.each_pair do |email, teams| Jobshop::TeamsMailer.found_teams(email, teams).deliver_later end redirect_to new_user_session_path end end end