app/models/batch.rb
# Create the tickets associated with this batch.
Create the tickets associated with this batch.
Create the tickets associated with this batch .
def create_tickets
    event = Event.where(eventbrite_event_id: Rails.application.config.eventbrite[:event_id]).first
    event_id = event ? event.id : nil
    self.emails.split(/\s+/).map(&:strip).each do |email|
      if ticket = self.tickets.detect {|ticket| ticket.email == email }
        ticket.update_attributes(ticket_kind: self.ticket_kind, batch: self)
      else
        ticket = Ticket.new(email: email, ticket_kind: self.ticket_kind, batch: self, event_id: event_id)
        self.tickets << ticket
      end
      Ticket.where(email: email, event_id: event_id).each do |prev_ticket|
        logger.warn "Warning: This email [#{email}] already has a #{prev_ticket.ticket_kind.title.upcase} ticket code, emailed status = #{prev_ticket.status.to_s.upcase} for this event."
      end
    end
  end
def create_tickets event = Event . where ( eventbrite_event_id : Rails . application . config . eventbrite [ :event_id ] ) . first event_id = event ? event . id : nil self . emails . split ( / \s + / ) . map ( & :strip ) . each do | email | if ticket = self . tickets . detect { | ticket | ticket . email == email } ticket . update_attributes ( ticket_kind : self . ticket_kind , batch : self ) else ticket = Ticket . new ( email : email , ticket_kind : self . ticket_kind , batch : self , event_id : event_id ) self . tickets << ticket end Ticket . where ( email : email , event_id : event_id ) . each do | prev_ticket | logger . warn "Warning: This email [#{email}] already has a #{prev_ticket.ticket_kind.title.upcase} ticket code, emailed status = #{prev_ticket.status.to_s.upcase} for this event." end end end
Create the tickets associated with this batch.
Create the tickets associated with this batch .
# TODO how to pass this message to controller/view