Undefined method `perform' for Class

Hello everybody,

i have some problem with workers

My controller

def import2
if params[:file].blank? or params[:company_id].blank? or
params[:label].blank?
flash[:alert] = “Veillez renseigner tous les champs”
@databases = DatabasesName.all.collect{|c| c.label}
redirect_to reassignments_import_path
else
@message = “Votre fichier a été bien enregistré. Il sera traité à
3 heures du matin. Merci”
filename=“import_reassignation_#{params[:company_id]}#{params[:label]}”+Time.now.strftime("%Y%m%d%H%M%S")+"_"+rand(100).to_s+".csv"
directory = “public/import”
path = File.join(directory, filename)
File.open(path, “wb”) { |f| f.write(params[:file].read) }
Resque.enqueue_at(Time.now.end_of_day + 3.hours, Reassignment,
path, params[:company_id].to_i, params[:label])
end
end

My model

class Reassignment < ActiveRecord::Base
require ‘csv’

@queue = :is2_low
def self.perfom(path, company_id, database)
Reassignment.resassign_ressources_directories(path, company_id,
database)
end
def self.resassign_ressources_directories(path, company_id, database)
ActiveRecord::Base.connection.close
DatabaseConnection.establish_connection “#{database}_#{Rails.env}”
data = []
reader= CSV.open(path, ‘r’)
reader.shift
reader.each do |row|
data = row
did = Directory.find_by_id_and_company_id(data[2].to_i,
company_id)
rs = Resource.find_by_id_and_company_id(data[3].to_i,
company_id)
int =Interview.where(directory_id: data[0].to_i, resource_id:
data[1].to_i, company_id: company_id)
unless did.nil? and rs.nil?
int.each do |i|
i.update_attributes(:resource_id=>rs.id,:uid=>rs.uid,:directory_id=>did.id,:source_id=>did.source_id)

      end
    end
 end
DatabaseConnection.connection.close

end
end

I start worker with:
rake resque:workers COUNT=5 QUEUE=*

When i run code i have this error on resque page:

undefined method perform' for #<Class:0x00000008a22e18> /home/eric/.rvm/gems/[email protected]/gems/activerecord-4.1.0/lib/active_record/dynamic_matchers.rb:26:inmethod_missing’

But when i run this:
Reassignment.perfom(“public/import/import_reassignation_62_database1_connection_20150502122112_98.csv”,
62, “database1_connection”)

it works well.

How can fix this error? Thank you

Hello Simon,

your question looks very Rails-ralated,
I thing you’ll have a much better chance of getting answers
in the neighbouring forum: https://www.ruby-forum.com/forum/rails

Sven

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs