All threads / Making a contacts form page, getting LoadError
Ask A Question


You’re not receiving notifications from this thread.

Making a contacts form page, getting LoadError

Kyle Williamson asked in Rails

Hello. I'm trying to create a contact page that emails me directly from the contact me page of my portfolio site. I created the contact form model by following this tutorial on YouTube. But I'm getting this error shown in the screenshot. !
Below is my contact.rb file

class ContactForm < MailForm::Base
  attribute :name,      :validate => true
  attribute :email,     :validate => /\A([\W\.%\+\-]+)@([\W\-]+\.)+([\W]{2,})\z/i
  attribute :message,   :validate => true
  attribute :nickname,  :captcha  => true

  def headers 
    :subject => "Contact Form",
    :to => "",
    :from => %("#{name}" <#{email}>)

And here is my contacts_controller.rb file:

class ContactsController < ApplicationController

  def index


  def new
    @contact =

  def create
    @contact =[:contact])
    @contact.request = request
    if @contact.deliver[error] = nil
    else[:error] = 'Cannot send message.'
      render :new


It's highlighting that @contact = line in the error. I'm just not understanding why. I need to define it from what the error says, but I just don't know where. Can someone help me?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 54,919+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.