Nexmo - Rails 中的未定义方法 send_message
Nexmo - Undefined method send_message in Rails
我正在尝试使用 nexmo 发送短信 gem,
几天前,代码运行良好。
def send_sms
@number = params[:number]
@nannytel = params[:phone]
nexmo = Nexmo::Client.new(
key: 'xxxxxxx',
secret: 'xxxxxxx'
)
notification = "The contact number is following #{@nannytel}"
response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)
if response['messages'].first['status'] == '0'
flash[:success] = "Yayy! We just sent you details for the nanny "
redirect_to root_path
else
flash[:alert] = "Uh Oh! Something went wrong, please try entering your number again"
redirect_to root_path
end
end
以上是pages controller中的方法
请修改以下代码
response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)
AS
response = nexmo.sms.send(
from: "SENDERID",
to: @number,
text: notification
)
根据 documentation 版本 5.0.2
需要进行上述更改
或
使用版本 4.8
而不是 5.0.2
gem 'nexmo', '4.8'
我正在尝试使用 nexmo 发送短信 gem,
几天前,代码运行良好。
def send_sms
@number = params[:number]
@nannytel = params[:phone]
nexmo = Nexmo::Client.new(
key: 'xxxxxxx',
secret: 'xxxxxxx'
)
notification = "The contact number is following #{@nannytel}"
response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)
if response['messages'].first['status'] == '0'
flash[:success] = "Yayy! We just sent you details for the nanny "
redirect_to root_path
else
flash[:alert] = "Uh Oh! Something went wrong, please try entering your number again"
redirect_to root_path
end
end
以上是pages controller中的方法
请修改以下代码
response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)
AS
response = nexmo.sms.send(
from: "SENDERID",
to: @number,
text: notification
)
根据 documentation 版本 5.0.2
或
使用版本 4.8
而不是 5.0.2
gem 'nexmo', '4.8'