Ruby on rails Rails 5.1:Post请求无法正常工作

Ruby on rails Rails 5.1:Post请求无法正常工作,ruby-on-rails,post,twilio,ruby-on-rails-5,authy,Ruby On Rails,Post,Twilio,Ruby On Rails 5,Authy,在我的Rails 5.1应用程序中,我使用将2fa添加到我的应用程序中。用这个表格 = enable_authy_form multipart: true do = text_field_tag :country_code, '', required: true, id: 'country_code', aria_required: 'true' = telephone_field :cellphone, '', required: true, autocomplete: 'of

在我的Rails 5.1应用程序中,我使用将2fa添加到我的应用程序中。用这个表格

= enable_authy_form multipart: true do
    = text_field_tag :country_code, '', required: true, id: 'country_code', aria_required: 'true'
    = telephone_field :cellphone, '', required: true, autocomplete: 'off', id: 'authy-cellphone', class: 'string required', aria_required: 'true'
    = button 'button', I18n.t( 'enable_authy', { scope: 'devise' } ), nil, 'submit', true, 'flex-end'
。。。我将发布到以下控制器操作():

但正如您从日志中看到的,没有发生任何事情:

Started POST "/2fa/enable" for 127.0.0.1 at 2017-06-24 21:19:02 +0200
Processing by Devise::DeviseAuthyController#POST_enable_authy as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"5P1aSzQvWATGEBLEYYwoD7dS/6sCSzpAk24rnh1DK9ZV6S70WWt10ijmoAo9MlxyGDAol+ewZYAszooiDeZKQQ==", "country"=>"United States", "country_code"=>"us", "cellphone"=>["546876578"], "subdomain"=>""}
Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.
  Rendering devise/devise_authy/enable_authy.html.haml within layouts/application
Completed 200 OK in 3632ms (Views: 2461.8ms | ActiveRecord: 1.5ms)
它只是重定向到模板,请求来自该模板。我不明白为什么会这样



即使在分叉gem之后,修改控制器以重定向到特定的
URL
,也不会发生任何事情。

我不确定它是否适用,因为我在Ruby/Sinatra中经历过这种情况。我的帖子似乎是对的,但它一直在返回原始表单。问题在于AJAX,它是默认的。由于AJAX打算更新表单,因此它不会以其他方式重定向。我指定data ajax=“false”来解决它。如果有帮助,请告诉我。(发表评论作为回答。)

我不确定发生了什么,鲁格下面的建议可能会有所帮助。我只是想知道为什么在这种情况下你的表单被设置为
multipart:true
?@philnash Dunno,我删除了它:)哦,我想我可能知道这里发生了什么。在哪里设置Authy API密钥?你能确认你确实在设置它吗?@philnash在一个初始值设定项中(
auth.rb
):
Authy.api\u key=Settings.designe.Authy.key
——除非
Authy.api\u key
有什么问题,否则我确信它是按预期的方式工作的。不过,我会根据秘密检查它是否设置正确。尝试在控制器中记录
Authy.api\u key
,看看结果如何。@jonhue有趣。你能告诉我你做了什么吗?如果有什么不同吗?嗯,到目前为止我还没有找到解决办法。我尝试了您的建议,显然,我试图通过使用分叉存储库来更改控制器操作。
Started POST "/2fa/enable" for 127.0.0.1 at 2017-06-24 21:19:02 +0200
Processing by Devise::DeviseAuthyController#POST_enable_authy as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"5P1aSzQvWATGEBLEYYwoD7dS/6sCSzpAk24rnh1DK9ZV6S70WWt10ijmoAo9MlxyGDAol+ewZYAszooiDeZKQQ==", "country"=>"United States", "country_code"=>"us", "cellphone"=>["546876578"], "subdomain"=>""}
Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.
  Rendering devise/devise_authy/enable_authy.html.haml within layouts/application
Completed 200 OK in 3632ms (Views: 2461.8ms | ActiveRecord: 1.5ms)