我正在使用ShopifyApp
宝石,它的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
而由宝石引擎输入的路线是:
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'
**我看到数据进来** - 请解释你在哪里看到这个?**但由于某种原因,它没有打我的接收方法,停在我的撬,我不知道为什么** - 它是否停在'binding.pry'? – dp7
我在控制台中看到它,并没有它没有击中'binding.pry'不知道为什么..我试过这个,但它没有工作.. [覆盖类中的Gem](http:// stackoverflow .com/questions/2688853/how-to-override-a-class-method-of-the-gem-in-rails-application) – ToddT
你可以添加日志吗? – dp7