我正在使用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