Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Making a contacts form page, getting LoadError

Rails • Asked by Kyle Williamson

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 => "[email protected]",
    :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?

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,152+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.