更新 我发布了30美元bounty,无论谁解决了这个问题。
我正在使用Checkout按钮并将结果发布到payola / subscribe / 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,其状态为pending,但是,负责通知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'
更新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: "alfredoreduarte@gmail.com", 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>]>
我开始认为这是一个问题,工人对这些模型没有任何线索。
更新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无关。
答案 0 :(得分:0)
错误消息的这一部分表明payola_subscriptions
表不在数据库中:
...relation "payola_subscriptions" does not exist...
检查bin/rake db:migrate
运行没有错误,并考虑使用数据库客户端手动检查数据库中是否存在payola_subscriptions
表。