I am getting error while i visit to the page localhost:3000/contacts
error of detials and source code is provided below.
wrong number of arguments (1 for 2)
Extracted source (around line #4):
2 attribute :name, :validate => true
3 attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
4 attribute :message
5 attribute :nickname, :captcha => true
here is code of model
class Contact < ApplicationRecord
attribute :name, :validate => true
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
attribute :message
attribute :nickname, :captcha => true
# Declare the e-mail headers. It accepts anything the mail method
# in ActionMailer accepts.
def headers
{
:subject => "HsbNoid",
:to => "iamhsb001@gmail.com",
:from => %("#{name}" <#{email}>)
}
end
end
here is code for controller
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(conact_params)
@contact.request = request
if @contact.deliver
flash.now[:notice] = 'Thank you for your message. We will contact you soon!'
else
flash.now[:error] = 'Cannot send message.'
render :new
end
end
private
def conact_params
params.require(:contact).permit(:name, :email, :message)
end
end
Aucun commentaire:
Enregistrer un commentaire