我已经建立了一个 POST 请求路由:
match '/getActivatedFriends',
to: 'requests#getActivatedFriends', via: 'post',
constraints: { friends_phone_number_csv: /([0-9]+,?)+/ }
用行动:
def getActivatedFriends
@results = BusinessUser.find_by_sql("SELECT
a.id
, a.username
, a.phoneNumber
FROM users a
WHERE phoneNumber in ('+params[:friends_phone_number_csv]+') and
removed = 0 and
is_user = 1;")
respond_to do |format|
format.html
format.json { render json: { friends_match: @results }}
end
end
这应该返回匹配用户的 JSON 对象。我用 POSTMAN 测试过:
但返回的是指出无效真实性令牌的错误
如何重新配置以使此 POST 路由正常工作?