連絡先フォームで、ユーザーは名前と電子メールのフィールドにメッセージとともに入力します。
class ContactForm < MailForm::Base
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 => "My Contact Form",
:to => "FILLTHISIN@example.com",
:from => %("#{name}" <#{email}>)
}
end
end
属性から自動的に送信しuser.email
、ユーザーがフィールドに入力しないようにしたい。これは可能ですか?