brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.64k stars 114 forks source link

undefined method `find' for Celluloid::Call:Class #153

Closed nynhex closed 8 years ago

nynhex commented 8 years ago

I'm working to integrate sucker_punch into a rails 3.2.22 app. I'm wrote a simple job that sends an email via ActionMailer see code below:

class NewCallJob
  include SuckerPunch::Job

  def perform(call_id)
    ActiveRecord::Base.connection_pool.with_connection do
      call = Call.find(call_id)
      CallMailer.new_call_notify(call).deliver
    end
  end
end

To test it out I fire it from a command line with a call id from the Call model the app is built around.

NewCallJob.new.async.perform(51631)

When firing it from the console no exception is raised in my session, but in my development log I see the following exception/stack trace.

NoMethodError: undefined method `find' for Celluloid::Call:Class
    /Users/jelinek/Dropbox/exigencad/app/jobs/new_call_job.rb:8:in `block in perform'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.20/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
    /Users/jelinek/Dropbox/exigencad/app/jobs/new_call_job.rb:5:in `perform'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/calls.rb:28:in `public_send'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/calls.rb:28:in `dispatch'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/call/sync.rb:16:in `dispatch'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/cell.rb:50:in `block in dispatch'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/cell.rb:76:in `block in task'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/actor.rb:339:in `block in task'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/task.rb:44:in `block in initialize'
    /Users/jelinek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/task/fibered.rb:14:in `block in create'

I am using sucker_punch 1.5.x. Does this look like a celluloid problem and if so what version of sucker_punch should I be using that would be compatible with Rails 3.2.22?

I was going to post this to stack but figured I'd drop an issue. It should be able to find the method find based off of the AR model Call that I have.

Thanks in advance.

nynhex commented 8 years ago

@brandonhilkert Ok, this looks to be an issue with my Model Call conflicting with the Celluloid Call class and clobbering each other. This entire app was built around the Call model. Is there any way I can work around this besides rewriting the app to acomodate celluoid?

brandonhilkert commented 8 years ago

Use "::" in front of your reference to "Call". So "call = ::Call.find(call_id)".

nynhex commented 8 years ago

@brandonhilkert Sorry I totally overlooked that. Sorry, it's late. Thanks for your super quick response :+1: