次のエラーが表示されます。
Error message: undefined local variable or method `call_alert_path' for #<RoadrunnerTwilioAlert:0x007f34401bbd10>
call_alert_path
ただし、ルートで適切に定義されているように感じます。これは、私のテストが合格したという事実によって裏付けられています。テスト モードと本番の主な違いは、本番では、呼び出すメソッドがcall_alert_path
非同期ジョブにあることです。call_alert_path
おそらくそれはそれを台無しにしています...とにかく、それ以外の場合は正しく定義されており、記述されたコードに問題がないことをコミュニティに確認したいだけです。
コントローラーコード:
# calls async job in production
if Rails.env == "production"
RoadrunnerTwilioAlert.new.async.perform(params[:rentalrequest_id])
else
@alert = twilio_client.account.calls.create(
from: ENV["Twilio_Verified_Phone"],
to: ENV["Roadrunner_Phone"],
url: call_alert_path,
method: 'post'
)
@request.update_attributes(twilio_alert: "call")
end
非同期ジョブ コード:
def perform(rentalrequest_id)
@request = Request.find(id)
@alert = twilio_client.account.calls.create(
from: ENV["Twilio_Verified_Phone"],
to: ENV["Roadrunner_Phone"],
url: call_alert_path,
method: 'post'
)
@request.update_attributes(twilio_alert: "call")
end
ルート:
match '/twilio/call_alert', to: 'twilio#call_alert', via: :post, as: "call_alert"