adding anchor in the controller

Paul
Fri, 08 Jul 2011 20:21:29 -0000

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?

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at