LoadError in CandidatesController#create
Unable to autoload constant Usermailer, expected Z:/railsassignment/student/app/mailers/usermailer.rb to define it
When I submit a form I get the error above. The form processes a record and the candidate is added to the database however the welcome email I'm trying to send to the newly registered candidate doesn't send, and the error above prevents the user from proceeding.
Candidates Controller
def create
@candidate = Candidate.new(candidate_params)
respond_to do |format|
if @candidate.save
Usermailer.welcome(@candidate).deliver_now ***<-- Error highlights this line***
format.html { redirect_to @candidate, notice: 'User was successfully
created.' }
format.json { render :show, status: :created, location: @candidate }
else
format.html { render :new }
format.json { render json: @candidate.errors, status:
:unprocessable_entity }
end
end
end
usermailer.rb
Z:/railsassignment/student/app/mailers/usermailer.rb (usermailer directory)
class UserMailer < ActionMailer::Base
default from: "from@example.com"
def welcome(candidate)
@candidate = candidate
mail(:to => candidate.can_email, :subject => "Welcome to EmployeMe.com, You
have registered successfully!")
end
end
Should you need to see any more of the files drop me a comment and I'll be quick to add them to the question.
Aucun commentaire:
Enregistrer un commentaire