class ContactController

Public Instance Methods

create() click to toggle source

Create new contact and send email

# File app/controllers/contact_controller.rb, line 9
def create
  @user = User.new
  @email = params[:email]
  @message = params[:message]
  @errors = { }

  if @message.nil? || @message.empty?
    @errors[:message] = "Message is mandatory"
  end

  if @errors.empty?
    ContactMailer.delay(queue: :mailer).new_contact(@email, @message)
    redirect_to(contact_path, :notice => "Message was successfully sent.")
  else
    flash.now.alert = "Please fill all fields."
    render :new
  end
end
new() click to toggle source

Intialize new object for user.

# File app/controllers/contact_controller.rb, line 4
def new
  @user = User.new
end