更新 我已經發布了一個30 $ bounty爲誰修復此問題。Payola工人失敗與'關係'payola_subscriptions「不存在'
我使用Checkout按鈕,並將結果張貼到payola /訂閱/ PLAN_CLASS/PLAN_ID.json
這是我initializers/payola.rb
Payola.configure do |config|
config.background_worker = :active_job
config.secret_key = 'yyy'
config.publishable_key = 'xxx'
config.subscribe('payola.subscription.active') do |sub|
user = User.find_by(email: sub.email)
sub.owner = user
sub.save!
end
config.subscribe 'charge.refunded' do |event|
sale = Payola::Sale.find_by(stripe_id: event.data.object.id)
sale.refund! unless sale.refunded?
end
end
被在payola_subscriptions表創建一個payola_subscription,但狀態爲掛起,負責通知Stripe的工作將失敗,並顯示以下跟蹤:
PG::UndefinedTable: ERROR: relation "payola_subscriptions" does not exist LINE 8: WHERE a.attrelid = '"payola_subscriptions"'::...^: SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod, (SELECT c.collname FROM pg_collation c, pg_type t WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation), col_description(a.attrelid, a.attnum) AS comment FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"payola_subscriptions"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:88:in `async_exec'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:88:in `block in query'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:560:in `log'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:87:in `query'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:739:in `column_definitions'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:227:in `columns'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/schema_cache.rb:56:in `columns'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/schema_cache.rb:62:in `columns_hash'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/model_schema.rb:354:in `load_schema!'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/attributes.rb:233:in `load_schema!'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/attribute_decorators.rb:28:in `load_schema!'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/model_schema.rb:349:in `load_schema'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/model_schema.rb:256:in `columns_hash'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/core.rb:192:in `block in find_by'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/core.rb:192:in `each'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/core.rb:192:in `all?'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/core.rb:192:in `find_by'
/Users/alfredo/.rvm/gems/ruby-2.3.1/bundler/gems/payola-db71531ac30c/app/services/payola/process_subscription.rb:4:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/bundler/gems/payola-db71531ac30c/lib/payola/worker/active_job.rb:17:in `perform'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/execution.rb:34:in `block in perform_now'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:126:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:286:in `block (2 levels) in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/i18n-0.7.0/lib/i18n.rb:257:in `with_locale'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/translation.rb:7:in `block (2 levels) in <module:Translation>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `instance_exec'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `block in make_lambda'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:285:in `block in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:447:in `block in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:286:in `block (2 levels) in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/logging.rb:24:in `block (4 levels) in <module:Logging>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:164:in `block in instrument'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:164:in `instrument'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/logging.rb:23:in `block (3 levels) in <module:Logging>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/logging.rb:44:in `block in tag_logger'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:70:in `block in tagged'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:26:in `tagged'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:70:in `tagged'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/logging.rb:44:in `tag_logger'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/logging.rb:20:in `block (2 levels) in <module:Logging>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `instance_exec'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `block in make_lambda'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:285:in `block in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:447:in `block in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_perform_callbacks'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/execution.rb:33:in `perform_now'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/execution.rb:22:in `block in execute'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:126:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:286:in `block (2 levels) in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/railtie.rb:26:in `block (4 levels) in <class:Railtie>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/execution_wrapper.rb:76:in `wrap'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/reloader.rb:68:in `block in wrap'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/execution_wrapper.rb:76:in `wrap'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/reloader.rb:67:in `wrap'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/railtie.rb:25:in `block (3 levels) in <class:Railtie>'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `instance_exec'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:391:in `block in make_lambda'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:285:in `block in halting'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:447:in `block in around'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_execute_callbacks'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/execution.rb:20:in `execute'
/Users/alfredo/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.0.1/lib/active_job/queue_adapters/resque_adapter.rb:44:in `perform'
UPDATE II
如上所述,我現在從寶石內部進行記錄。這是process_subscription.rb
現在的樣子:
module Payola
class ProcessSubscription
def self.call(guid)
p 'All subscriptions:', Payola::Subscription.all
Subscription.find_by(guid: guid).process!
end
end
end
這是輸出:
9:48:07 PM worker.1 | "All subscriptions:"
所以,基本上沒有Subscription
項可言。
有趣的是,這是我從Rails的控制檯中看到:
2.3.1 :002 > Payola::Subscription.all
Payola::Subscription Load (1.2ms) SELECT "payola_subscriptions".* FROM "payola_subscriptions"
=> #<ActiveRecord::Relation [#<Payola::Subscription id: 1, plan_type: "SubscriptionPlan", plan_id: 1, start: nil, status: nil, owner_type: nil, owner_id: nil, stripe_customer_id: nil, cancel_at_period_end: nil, current_period_start: nil, current_period_end: nil, ended_at: nil, trial_start: nil, trial_end: nil, canceled_at: nil, quantity: 1, stripe_id: nil, stripe_token: "tok_19ET9sCkWqwXsgpuB2MAdl1k", card_last4: nil, card_expiration: nil, card_type: nil, error: nil, state: "pending", email: "[email protected]", created_at: "2016-11-11 00:44:45", updated_at: "2016-11-11 00:44:45", currency: "usd", amount: 2900, guid: "d577sp", stripe_status: nil, affiliate_id: nil, coupon: nil, signed_custom_fields: nil, customer_address: nil, business_address: nil, setup_fee: nil, tax_percent: nil>]>
我開始認爲這是與不具有這些車型的線索工人的問題。
UPDATE III
原來,resque沒有看到任何我的PostgreSQL的表,雖然我跑這在lib/tasks/resque.rake
:
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
Resque.before_fork = Proc.new do |job|
ActiveRecord::Base.connection.disconnect!
end
Resque.after_fork = Proc.new do |job|
ActiveRecord::Base.establish_connection
end
end
它無關Payola。
它確實存在,我可以用我自己的眼球看到它(?)即使是條目(訂閱),也存在與process_subscription.rb:4正在接收的相同'guid'作爲參數。 –
感謝您的更新。接下來你可能會嘗試的是調試'ProcessSubscription'作業。在工作中,如果你有'pry'設置或者使用打印調試來檢查作業是否能夠看到'payola_subscriptions'表,那麼使用'binding.pry'。打印調試嘗試:'p'所有訂閱:',Payola :: Subscription.all' –
感謝您的建議!我剛剛更新了結果的問題。 –