Re: adding anchor in the controller

Conrad Taylor
Fri, 08 Jul 2011 20:33:38 -0000

On Fri, Jul 8, 2011 at 1:21 PM, Paul
<paul-mzPrHiy5csbYtjvyW6yDsg@public.gmane.org> wrote:

> 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
>
>
Does the user click on a link that contains the above URL?

-Conrad


> 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
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

--
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