I’d like to rewrite a URL that is passed to me by turning the
parameter into an anchor tag. In other words, if the user requests:
/my_controller?q=123
I will handle it in the index action, but I want the user’s browser to
show this URL instead:
/my_controller#123
I know I could redirect to a different action. The following works:
def index
do stuff
end
def query
anchor = params[:q]
redirect_to(:action => ‘index’, :anchor => anchor)
end
Now if the user requests:
/my_controller/query?q=123
Their browser will say:
/my_controller#123
but how do I do it if I’m already in the correct action?