NoMethodError (undefined method `trigger_file_background_processing?' #69

Closed
waynehoover opened this Issue Oct 3, 2012 · 6 comments

Comments

Projects
None yet
4 participants

Getting this error

NoMethodError (undefined method `trigger_file_background_processing?'

Using the master branch, when not using the master branch it just seems to fail silently. Using sidekiq. Rails 3.2.8. Any ideas?

This is what I have in my model.rb:

  mount_uploader :file, FileUploader
  process_in_background :file

vtabary commented Oct 4, 2012

I think there is a bug in the master branch.

In file lib/backgrounder/orm/base.rb, "super" is used to get "trigger#{column}_background_processing?" and "trigger#{column}_background_storage?" which are generated by CarrierWave::Backgrounder::ORM::Base.

But those functions are redefined by the current ORM class (ORM::ActiveRecord, ORM::Mongoid, ...), so Ruby gets no trace from this.

We shouldn't use "super" here. Maybe we should define a new private method which will be shared and called by all derived classes if necessary.

vtabary commented Oct 4, 2012

I modified those files in this commit vtabary/carrierwave_backgrounder@4bb7079

Owner

lardawge commented Oct 15, 2012

@vtabary, I am lost as to what you mean. This is how super works.

module A
  def junky?(name)
    puts 'In A#junk'
    name == "Bastard"
  end
end

module B
  include A

  def junky?(name)
    puts 'In B#junk'
    super && name =~ /Bas/
  end
end

class Main
  include B
end

c = Main.new

puts c.junky? "Bastard" # 0
puts c.junky? "Jim" # false

Is this only in Mongoid?

Contributor

jayzes commented Oct 15, 2012

I think the issue here is with class_eval, not super itself. Both the Base and ORM-specific modules class_eval method definitions into the base class, but class_eval does not alter the inheritance chain, so the second class_eval clobbers the first and makes super break.

A workaround might be to mix in anonymous modules instead of class_eval-ing. That would achieve the desired behavior.

Owner

lardawge commented Oct 15, 2012

Gotcha. Can you submit a patch? I would like to release 0.0.8 today.

@lardawge lardawge closed this in 1fb42dd Oct 15, 2012

Contributor

jayzes commented Oct 16, 2012

Submitted as #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment