Class: TicketMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/ticket_mailer.rb

Overview

This class send collect the tickets notification

Instance Method Summary collapse

Instance Method Details

#confirm(ticket) ⇒ Object

Send confirmation email for a ticket

Parameters:

  • ticket (Object)

    istance of created Ticket



5
6
7
8
9
# File 'app/mailers/ticket_mailer.rb', line 5

def confirm(ticket)
  @ticket = ticket
  @happening = @ticket.happening
  mail to: @ticket.user.email, subject: subject(action: "confirm", date: @happening.start_at)
end

#deleted(ticket) ⇒ Object

Send notify email on destroy ticket

Parameters:

  • ticket (Object)

    istance of destroyed Ticket



13
14
15
16
17
18
# File 'app/mailers/ticket_mailer.rb', line 13

def deleted(ticket)
  @ticket = ticket
  @happening = @ticket.happening
  @tickets = Ticket.where(user: ticket.user, happening: ticket.happening)
  mail to: @ticket.user.email, subject: subject(action: "deleted", date: @happening.start_at)
end

#reminder(happening, user) ⇒ Object

Send reminder for an event happeningf

Parameters:

  • happening (Object)

    Istance of Happening to remind

  • user (Object)

    Istance of User send remind. If user have not ticket the remind is not sended



23
24
25
26
27
28
# File 'app/mailers/ticket_mailer.rb', line 23

def reminder(happening, user)
  @happening = happening
  @user = user
  @counter = @happening.tickets.with_user(@user).count
  mail to: @user.email, subject: subject(action: "reminder", date: @happening.start_at) if @counter > 0
end