在准备与Twilio API的连接时
def send_text(user, message)
client.api.account.messages.create(
to: user.telefono_mobile,
from: phone_number,
status_callback: update_twilio_reminder_url.to_s,
body: message
)
end
消息状态的回调必须为URL。但是,此语法无法访问rails的helper方法,并返回错误undefined local variable or method 'update_twilio_reminder_url'
正确的语法是什么?
答案 0 :(得分:1)
您是否尝试在控制器中include Rails.application.routes.url_helpers
?
在较新的Rails中(我猜是5个),它也足以通过helpers.helper_method
调用helper方法,但我从未尝试过。