Ruby on rails 如何验证从我的网站上的其他网站发送的查询字符串

Ruby on rails 如何验证从我的网站上的其他网站发送的查询字符串,ruby-on-rails,ruby-on-rails-5,Ruby On Rails,Ruby On Rails 5,我有一个连接到API的网站,它要求我生成一个参考代码以及完成注册所需的其他信息。确认注册后,服务器将响应重定向到我的控制器操作,以完成整个过程,在此过程中,我必须用另一个控制器操作验证。然而,我尝试了以下方法,但仍然有一些困难使我的网站响应重定向ie:显示消息“book confirmed!” Here is the url i get: http/example.com/?ref=2755558333388=referencecode=2755558333388 instead of

我有一个连接到API的网站,它要求我生成一个参考代码以及完成注册所需的其他信息。确认注册后,服务器将响应重定向到我的控制器操作,以完成整个过程,在此过程中,我必须用另一个控制器操作验证。然而,我尝试了以下方法,但仍然有一些困难使我的网站响应重定向ie:显示消息“book confirmed!”

Here is the url i get: 
  http/example.com/?ref=2755558333388=referencecode=2755558333388
instead of        
  http/example.com/book?ref=2755558333388=referencecode=2755558333388



# route
Rails.application.routes.draw do
   get 'confirmations/register'
   post 'confirmations/verified'
end


# controller:

class ConfirmationsController < ApplicationController
  def register
    registerationObj = Registration.new(ENV["BOOKREG_PUBLIC_KEY"], ENV["BOOKREG_PRIVATE_KEY"])
    book = RegistrationBooks.new(registrationObj)
    :action = books.create(
        :book_title => @book.title,
        :phone => current_user.phone,
        :email => current_user.email,
        :referencecode => @book.referencecode
  end

  def verified
    if params[:referencecode == @book.referencecode
      flash[:alert] = "Your book has been verified"
      redirect_to books_path
    else
      redirect_to current_user_edit_path, notice: "Sorry your book was not verified"
    end
  end
以下是我得到的url:
http/example.com/?ref=2755558333388=referencecode=2755558333388
而不是
http/example.com/book?ref=2755558333388=referencecode=2755558333388
#路线
Rails.application.routes.draw do
获取“确认/登记”
发布“确认/验证”
结束
#控制器:
类确认控制器<应用程序控制器
def寄存器
registrationobj=Registration.new(ENV[“BOOKREG\u PUBLIC\u KEY”]、ENV[“BOOKREG\u PRIVATE\u KEY”])
book=RegistrationBooks.new(registrationObj)
:action=books.create(
:book_title=>@book.title,
:phone=>current_user.phone,
:email=>current_user.email,
:referencecode=>@book.referencecode
结束
def验证
如果参数[:referencecode==@book.referencecode
flash[:alert]=“您的书已被验证”
重定向到图书路径
其他的
将\重定向到当前\用户\编辑\路径,注意:“对不起,您的书未经验证”
结束
结束

为什么您希望重定向到
/verified
而不是
/
?您在使用该API时是否配置了该重定向?或者API文档中是否说明了这一点?我的意思是,您说您有一些url而不是另一个url,但您没有说明为什么会这样。从您的路由中,您甚至希望路径是正确的
/confirmations/verified
,而不仅仅是
verified
感谢您的回复。文档中说它将在call\u-back参数上附加查询字符串,在这种情况下:www.example.com/books/?ref=2755558333388=referencecode=2755558333388。谢谢什么是“call\u-back参数”?我在代码中没有看到任何名为
call_back
或类似的参数。您在哪里告诉API您希望重定向位于/验证(既然您希望它是该url,为什么您希望它是该url?)?请问,@arieljuod是否有办法将调用添加回控制器,以响应api服务器的重定向,从而重定向到“已验证”操作?如果有,请help@arieljuod谢谢,您的问题帮助了我。我发现我没有在api上正确配置回调url。而不是提供“https”//example.com/confirmations/verified',我提供了“https//example.com/”非常感谢,干杯!