Hi all Im pretty new to Ruby on Rails. My boss created an app and is asking me to create a worker to email us when there is a conflict of events for a DJ. It works in the terminal but Im having problems getting the event details of the conflict to display in my mailer. Im trying to test it out with mail catcher to see if Im doing it correctly but I do not know what to pass for the overlaps parameter in my test. Below is my code. Can someone help me out?
My worker says this(PLEASE LOOK AT THE CAPS) *class TalentConflictsWorker* * include Sidekiq::Worker* * include Sidetiq::Schedulable* * sidekiq_options retry: false* * MAX_CALENDARS_TO_SCHEDULE_AT_ONCE=10* * def perform (user_id)* * user=User.find(user_id)* * events=user.calendar.events* * events.each do |e|* #Checking for conflicting events. If not the same event and has an overlap, display name and start date. * overlaps=events.where("(strftime('%s',start) - strftime('%s',?)) * (strftime('%s',?) - strftime('%s',end)) >= 0" , e.start, e.end ).where.not(id: e.id)* * overlapsflag=overlaps.present?* #overlaps=where("(start,events.end) OVERLAPS (timestamp ?, timestamp ?)" AND not(id: e.id).present? * if overlapsflag* * CalendarMailer.talent_conflict(user, events, overlaps).deliver* *#FOR TERMINAL <---THIS WORKS IN THE TERMINAL (when uncommented) MY ISSUE IS HOW DO I PASS THE OVERLAPS AND GET THOSE EVENTS TO DISPLAY IN THE EMAIL* #puts "Conflict found", e.name, e.start #overlaps.each do |overlap_event| #puts overlap_event.name #puts overlap_event.start #overlapstring=overlap_event.to_s #end #else #puts "NO EVENT CONFLICT FOUND" * end * * end * * end* *end* *Heres the mailer I THOUGHT PERHAPS I PUT THE DO LOOP IN THE MAILER? * *def talent_conflict(user, events, overlaps)* * @user=user* * @events=events* * @overlaps= overlaps* * overlaps.each do |overlap_event|* * puts overlap_event.name* * puts overlap_event.start* * #overlapstring=overlap_event.to_s* * end* * mail(subject: "SMG Talent: detected an event conflict )")* * end* *THIS IS THE HTML * *<p>Event conflicts have been detected.</p>* *<ul>* *<li><%= @events.name %> held on <%= @events.start %> conflicts with the following event: <%= @overlaps.name %><%= @overlaps.start %></li>* *</ul>* -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.