Class: ContactForm
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ContactForm
- Includes:
- MailForm::Delivery
- Defined in:
- app/models/contact_form.rb
Overview
== Schema Information
Table name: contact_forms
Database name: primary
id :integer not null, primary key
object :jsonb
type :string(50) not null
created_at :datetime
updated_at :datetime
creator_id :integer
visit_id :integer
Indexes
index_contact_forms_on_visit_id (visit_id) WHERE (visit_id IS NOT NULL) USING hash
Foreign Keys
fk_rails_... (visit_id => visits.id) ON DELETE => nullify
Direct Known Subclasses
MailForm::CustomProductTraining, MailForm::CustomProductTrainingEmail, MailForm::EnrollModelHomeProgram, MailForm::EnrollNameYourOwn, MailForm::EnrollShowroomProgram, MailForm::EnrollSocialMedium, MailForm::EnrollSpiff, MailForm::PersonalConnect, MailForm::PipeFreezeProtectionQuote, MailForm::ProductSample, MailForm::Quote, MailForm::QuoteRequest, MailForm::QuoteRequestComplex, MailForm::QuoteRequestSimple, MailForm::RequestLiterature, MailForm::RoofGutterDeicingQuote, MailForm::ShareYourStory, MailForm::UploadPhoto, MailForm::WarrantyCountertopHeating, MailForm::WarrantyDeicing, MailForm::WarrantyDeicingKit, MailForm::WarrantyFloorHeating, MailForm::WarrantyLedMirror, MailForm::WarrantyMirrorDefogger, MailForm::WarrantyPipeTracing, MailForm::WarrantyRadiantPanel, MailForm::WarrantyShowerWaterproofingSystem, MailForm::WarrantySnowMelting, MailForm::WarrantyTowelWarmer
Constant Summary collapse
- EMAIL_REGEXP =
RFC822::EMAIL
Belongs to collapse
Has many collapse
Instance Method Summary collapse
- #email_sender_name ⇒ Object
- #from ⇒ Object
- #headers ⇒ Object
- #to ⇒ Object
- #type_cast_order_date ⇒ Object
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Method Details
#email_sender_name ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/contact_form.rb', line 40 def email_sender_name names = [] names << try(:company_name) names << try(:customer_name_or_id) names << try(:first_name) names << try(:last_name) names << try(:name) names.compact! names.join(' ') end |
#from ⇒ Object
66 67 68 69 70 71 72 |
# File 'app/models/contact_form.rb', line 66 def from if email_sender_name.present? %("#{email_sender_name}" <#{email_address}>) else email_address end end |
#headers ⇒ Object
75 76 77 78 79 80 81 |
# File 'app/models/contact_form.rb', line 75 def headers { subject: "[#{self.class.name}] (#{id}) #{email_sender_name}", to: to, from: from } end |
#to ⇒ Object
62 63 64 |
# File 'app/models/contact_form.rb', line 62 def to 'webmaster@warmlyyours.com' end |
#type_cast_order_date ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/models/contact_form.rb', line 52 def type_cast_order_date return unless respond_to?(:order_date) return if order_date.blank? return if order_date.is_a?(Date) # Cast string to date, preserve original value if parsing fails parsed = Date.parse(order_date.to_s) rescue nil self.order_date = parsed if parsed end |
#uploads ⇒ ActiveRecord::Relation<Upload>
30 |
# File 'app/models/contact_form.rb', line 30 has_many :uploads, as: :resource, dependent: :destroy |