Commit c68d20d71a2cff9d52204a7eabfb6afff8f2ef93

Authored by Antonio Terceiro
1 parent e98b918f

Fix problem with Delayed::Job and acts_as_ferret

For some reason when the Profile class is loaded while InvitationJob is
being performed there is an IOError error caused by acts_as_ferret's DRB
server. By trial and error I found out that if the class is loaded
during delayed_job startup, then that problem does not occur.

WTF?

(ActionItem1640)
Showing 2 changed files with 5 additions and 8 deletions   Show diff stats
lib/invitation_job.rb
1 class InvitationJob < Struct.new(:person_id, :contacts_to_invite, :message, :profile_id, :contact_list_id) 1 class InvitationJob < Struct.new(:person_id, :contacts_to_invite, :message, :profile_id, :contact_list_id)
2 def perform 2 def perform
3 - begin  
4 - person = Person.find(person_id)  
5 - profile = Profile.find(profile_id)  
6 - Invitation.invite(person, contacts_to_invite, message, profile)  
7 - ContactList.find(contact_list_id).destroy  
8 - rescue ActiveRecord::NotFound => e  
9 - #...  
10 - end 3 + person = Person.find(person_id)
  4 + profile = Profile.find(profile_id)
  5 + Invitation.invite(person, contacts_to_invite, message, profile)
  6 + ContactList.find(contact_list_id).destroy
11 end 7 end
12 end 8 end
script/delayed_job
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) 9 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
10 require 'daemons' 10 require 'daemons'
11 require 'delayed/command' 11 require 'delayed/command'
  12 +require 'app/models/profile'
12 13
13 ENV['RAILS_ENV'] ||= "production" 14 ENV['RAILS_ENV'] ||= "production"
14 Delayed::Command.new(ARGV).daemonize 15 Delayed::Command.new(ARGV).daemonize