简体   繁体   English

Rails请求引荐来源网址不包含#xxx

[英]Rails request referrer doesn't contain the #xxx

I have a Rails 3 form where I'm using Bootstrap tabs. 我有一个使用Bootstrap选项卡的Rails 3表单。 Each tab renders a different form (but to the same controller). 每个选项卡均呈现不同的形式(但呈现给相同的控制器)。

When I submit the form on tab2, the URL at the top of the page is: 当我在tab2上提交表单时,页面顶部的URL是:

http://localhost:3000/costprojects/1#tab2

In the costprojects controller, I want to go to the next tab when the user submits a form. 在costprojects控制器中,当用户提交表单时,我想转到下一个选项卡。

I thought this would work: 我认为这可以工作:

  def update
    @costproject = Costproject.find(params[:id])
    nextpath =  costproject_path(@costproject) + '#tab2'
    nextpath =  costproject_path(@costproject) + '#tab3' if request.referer.include?("#tab2")
    nextpath =  costproject_path(@costproject) + '#tab4' if request.referer.include?("#tab3")


    respond_to do |format|
      if @costproject.update_attributes(params[:costproject])
        format.html { redirect_to nextpath, notice: 'Capital Project was successfully updated.' } 

But, the request.referer doesn't include the 'tab2'. 但是, request.referer不包含“ tab2”。

How come? 怎么会?

Thanks for the help! 谢谢您的帮助!

The anchor is only available client side. 锚仅在客户端可用。 It's never sent as part of any request header. 它永远不会作为任何请求标头的一部分发送。 See Is the anchor part of a URL being sent to a web server? 请参阅URL的锚点部分是否发送到Web服务器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM