【发布时间】:2016-08-14 20:01:32
【问题描述】:
我正在使用ShopifyApp gem,它的WebhooksController 中有一个名为receive 的操作。如此处所示:Webhooks controller
在我的 WebhooksController 控制器中,我试图通过执行以下操作来覆盖 receive 操作:
class WebhooksController < ShopifyApp::WebhooksController
def receive
binding.pry
end
end
我到WebhooksController 的路线是这样的:
webhooks_receive POST /webhooks/receive(.:format) webhooks#receive
而Gem引擎放入的路由是:
webhooks POST /webhooks/:type(.:format) shopify_app/webhooks#receive
我看到数据进来了,但由于某种原因,它没有达到我的 receive 操作并在我的 pry 处停止,我不确定为什么。
Found this and tried it, but no luck.
I tried this solution too and it didn't work..
有什么想法吗?
以下是我的日志顶部显示正在发生的事情:
Started POST "/webhooks/receive" for XX.XXX.37.116 at 2016-04-21 14:57:02
+0000
Cannot render console from XX.XXX.37.116! Allowed networks: XXX.0.0.1, ::1,
127.0.0.0/127.XXX.XXX.255
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".*
FROM "schema_migrations"
Processing by ShopifyApp::WebhooksController#receive as */*
Parameters: {"rate"=>{"origin"=>{"country"=>"US", "postal_code"=>"48615",
"province"=>"MI", "city"=>"Breckenridge", "name"=>nil, "address1"=>"6760..
bunch of data removed for brevity}}}
Completed 500 Internal Server Error in 6ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `variable_size_secure_compare' for
ActiveSupport::SecurityUtils:Module):
shopify_app (7.0.2) lib/shopify_app/webhook_verification.rb:20:in
`hmac_valid?'
还有我的路线文件
Rails.application.routes.draw do
root :to => 'home#index'
mount ShopifyApp::Engine, at: '/'
resources :store
resources :shipping_methods
post '/webhooks/receive', to: 'webhooks#receive'
post '/billing_plans', to: 'billing_plans#save_plan', as: 'save_plan'
get '/activate_charge', to: 'billing_plans#activate_charge', as: 'activate'
post '/create_charge', to: 'billing_plans#create_charge', as:
'create_billing_plan'
【问题讨论】:
-
我看到数据进来了 - 请解释一下你在哪里看到的? 但由于某种原因,它没有击中我的接收方法并停止在我的 pry 处,我不确定为什么 - 它是否停止在
binding.pry处? -
我在控制台中看到了它,但它没有击中
binding.pry无法弄清楚为什么..我试过这个但它没有用..Override class in Gem -
可以添加日志吗?
-
见鬼,如果有帮助的话,我会加我的车!用日志更新了问题..
-
路径好像被shopify覆盖了,你也可以添加路由文件吗?
标签: ruby-on-rails rubygems shopify