我已经根据我的要求使用了一些 API。作为回应,我收到了一些动态错误消息。我想将错误消息放在 if 条件中,以便在条件内我可以根据我的要求编写一些代码。
这是错误信息。
"errormessage"=>"令牌 webapi2-26631123a246241356880 的登录会话已过期或无效。"
这个 webapi2-26631123a246241356880 将动态生成。我喜欢这个动态错误消息的 if 条件。
我已经根据我的要求使用了一些 API。作为回应,我收到了一些动态错误消息。我想将错误消息放在 if 条件中,以便在条件内我可以根据我的要求编写一些代码。
这是错误信息。
"errormessage"=>"令牌 webapi2-26631123a246241356880 的登录会话已过期或无效。"
这个 webapi2-26631123a246241356880 将动态生成。我喜欢这个动态错误消息的 if 条件。
h = {"errormessage"=>"Login session for token webapi2-26631123a246241356880 is expired or invalid."}
h["errormessage"].include? "webapi2-" #=> true
if h["errormessage"].include? "webapi2-"
#your code here
end
@webapi = Webapi.find(params[:token])
if coondition true
#your logic here
else
flash[:alert] = "Login session for token " + @webapi.token + "is expired or invalid."
render :template => 'path/to/template'
end