Reputation: 5953
I have a Rails 3 form where I'm using Bootstrap tabs. 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:
http://localhost:3000/costprojects/1#tab2
In the costprojects controller, I want to go to the next tab when the user submits a form.
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'.
How come?
Thanks for the help!
Upvotes: 1
Views: 346
Reputation: 19879
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?
Upvotes: 1