ruby on rails - Using Sidekiq to run more complex jobs -


edit: simple, forgot pass in site , token

i have setup sidekiq , redis on heroku , able work simple jobs this:

order_worker.rb

class orderworker     include sidekiq::worker     sidekiq_options retry: false      def perform(num_orders)       x=3*5     end end 

but more complex jobs keep failing according sidekiq web ui. need include shopifyapi , faker somehow? i'm not super clear on being run. entire app, gems , being created in worker dyno?

order_worker.rb

class orderworker     include sidekiq::worker     sidekiq_options retry: false      def perform(num_orders)         include shopifyapi         include faker          # initialize session         session = shopifyapi::session.new(site, token)         shopifyapi::base.activate_session(session)            #create orders         num_orders.times             new_order = shopifyapi::order.new(               :line_items => [                 shopifyapi::lineitem.new(                   :quantity => 1,                   :variant_id => 25701798472                 )               ]             )             new_order.billing_address = shopifyapi::billingaddress.new(:name => faker::name.name, :zip => zips[rnd], :country => 'united states', :province => states[rnd], :address1 => faker::address.street_address, :city => faker::address.city)             new_order.email = r.rand(36**2).to_s(36) + '@yahoo.com'             new_order.created_at = faker::time.backward(390, :evening)             new_order.total_price = faker::number.decimal(3, 2)             new_order.save             @errs = @errs + new_order.errors.full_messages             sleep 0.03         end      end   end 

notice orderworker#perform instance method, means runs in scope of instances of orderworker, not in class orderworker itself. instances don't have method include. belongs class. consequence you'll nomethoderrors when task run.

p.s. seems don't have include anything. remove includes inside perform make worker work.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -