Class: Dust::Contact

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/dust/contact.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.page(search, page, date) ⇒ Object



14
15
16
# File 'app/models/dust/contact.rb', line 14

def self.page(search, page, date)
  search(search, date).order("created_at DESC").paginate(:per_page => 12, :page => page)
end

.search(search, date) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/models/dust/contact.rb', line 23

def self.search(search, date)
  if search
    where("name LIKE ? OR email LIKE ? OR message LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%")
  elsif date
    where("date(created_at) IS ?", (Time.at(date.to_i / 1000)).to_date)
  else
    scoped
  end
end

.total_on(date) ⇒ Object



10
11
12
# File 'app/models/dust/contact.rb', line 10

def self.total_on(date)
  where("date(created_at) = ?", date)
end

Instance Method Details

#deliver_messagesObject



18
19
20
21
# File 'app/models/dust/contact.rb', line 18

def deliver_messages
  Dust.config.mailer.contact_confirmation(self).deliver
  Dust.config.mailer.contact_request(self).deliver
end