I am creating a module in my rails application for "adding team members" to a project. And im using devise_invitable.
In this if i add a new email address both the confirmation mail and invitaion mail is being sent ... as that makes more sense
I just want the invitation mail to be sent (and after the user accepts the invitation mail he can be sent to the registration page) ... it does not make sense to confirm before accepting the invite.
My current code is as follows :
def create_team_members
# find the case
@case = Case.find_by_id(params[:id])
# TODO:: Will change this when add new cse functionality is done
params[:invitation][:email].split(',').map(&:strip).each do |email|
# create an invitation
@invitation = Invitation.new(email: "#{email}".gsub(/\s+/, ''), role: params[:invitation][:role].rstrip, case_id: @case.id, user_type_id: params[:invitation][:user_type_id])
if @invitation.save
# For existing users fire the mail from user mailer
if User.find_by_email(email).present?
UserMailer.invite_member_instruction(@invitation).deliver
@invitation.update_attributes(invited_by: current_user.id)
else
# For new users use devise invitable
user = User.invite!(email: "#{email}", name: "#{email}".split('@').first.lstrip)
user.skip_confirmation!
user.save
@invitation.update_attributes(invitation_token: user.invitation_token, invited_by: current_user.id)
end
end
end
redirect_to dashboard_path
end
I dont know what im doing wrong ...
Please help ...thanks.