Hi you all, I have a RESTful app where my link_to is something like <%= link_to("Trial",sdrs_query_path(params[:id] + " = " + my_transf(@value))) %> When click on the link, the URL that appears is: http://localhost:3007/sdrs/queries/vlan_interfaz%3DTrial Is there anyway to avoid this? I want the equal sign as it is in the URL. Besides, the behaviour is strange. Even though the resulting URL is this: http://localhost:3007/sdrs/queries/vlan_interfaz%3DTrial if I change it manually into the browser to this one: http://localhost:3007/sdrs/queries/vlan_interfaz=Trial it works the same. I mean, it''s great Rails encode URLs automatically, but if there is no need (as in this case)... PT 1: the "manual" URL "queries/vlan_interfaz=Trial" works even thoug with query params such as "queries/vlan_interfaz=Trial?page=3". This is the reason why I say here there is no need in encoding. PT 2: With a simple <a href=...> it does not happen. I would use this way but my_transf(@value), a method that encodes "@value", returns the value as it is too, not encoded... :S Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Feb-13 17:48 UTC
Re: "link_to" helper: Looking for no encoding in URLs
this should work: <%= link_to("Trial", sdrs_query_path(params[:id] => my_transf(@value)) %> maybe you would have to use params[:id].to_sym, i''m not sure, if this conversion is implicit -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-13 18:01 UTC
Re: "link_to" helper: Looking for no encoding in URLs
Hi, your solution returns /query/value However, I want /query/key=value The "to_sym" behaves the same :( Thorsten Mueller wrote:> this should work: > > <%= link_to("Trial", sdrs_query_path(params[:id] => my_transf(@value)) > %> > > maybe you would have to use params[:id].to_sym, i''m not sure, if this > conversion is implicit-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Feb-13 18:29 UTC
Re: "link_to" helper: Looking for no encoding in URLs
maybe your routing is different... i used this with restful routing on an index action, that does not expect any additional params so: <% test = {:id => "foo"}%> <%= link_to(''Test'', played_tracks_path(test[:id] => "bar")) %> returned the correct result with /played_tracks?foo=bar but for the show action or any not restful routing it would fail that way if you have an index action, maybe: sdrs_queries_path(...) would work -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-13 18:40 UTC
Re: "link_to" helper: Looking for no encoding in URLs
Um...your problem is different I want to do something like query/:id where :id may be "key=value" You see? The entire url is a path URL, not a query URL. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Feb-13 18:58 UTC
Re: "link_to" helper: Looking for no encoding in URLs
ok, i''m not sure, this is what you want (maybe you should post some more info about your routing etc) routes.rb: map.resources :play_entries view: <% test = {:id => "foo"}%> <% value = "bar"}%> <%= link_to(''Test'', play_entry_path(test[:id] + "=" + value)) %> generates: <a href="/play_entries/foo=bar"> which would call the show action in my case... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-13 19:56 UTC
Re: "link_to" helper: Looking for no encoding in URLs
I was doing that, but the result of link_to was: <a href="play_entries/foo%3Dbar"></a> Thorsten Mueller wrote:> ok, i''m not sure, this is what you want (maybe you should post some more > info about your routing etc) > > routes.rb: > map.resources :play_entries > > view: > <% test = {:id => "foo"}%> > <% value = "bar"}%> > <%= link_to(''Test'', play_entry_path(test[:id] + "=" + value)) %> > > generates: > <a href="/play_entries/foo=bar"> > > which would call the show action in my case...-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Feb-14 09:21 UTC
Re: "link_to" helper: Looking for no encoding in URLs
Damaris Fuentes wrote:> I was doing that, but the result of link_to was: > > <a href="play_entries/foo%3Dbar"></a> >it worked in my case. did you copy my example? maybe it has to do with the routing and the kind of action. eg my example worked on the index action, which does not need an id parameter. your sdrs_query_path (singular path) should call the show action and therefore expect the id as first parameter. in this case it may handle things different. or there are differences in the rails versions? i simply can''t reproduce it in the way it works for you... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Feb-14 11:40 UTC
Re: "link_to" helper: Looking for no encoding in URLs
On 13 Feb 2008, at 16:49, Damaris Fuentes wrote:> > PT 1: the "manual" URL "queries/vlan_interfaz=Trial" works even thoug > with query params such as "queries/vlan_interfaz=Trial?page=3". This > is > the reason why I say here there is no need in encoding. >= is a reserved character in paths according to http://www.ietf.org/rfc/rfc2396.txt 3.3 which probably means you shouldn''t use it like that. ''It works'' isn''t usually a good test for these sort of things. You may be relying upon quirks of one particular web browser, server etc... Fred> PT 2: With a simple <a href=...> it does not happen. I would use this > way but my_transf(@value), a method that encodes "@value", returns the > value as it is too, not encoded... :S > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-14 12:55 UTC
Re: "link_to" helper: Looking for no encoding in URLs
Hi all, yes, you''re right, and I can try with another character. The thing is that, for example, the character "|" is not a reserved character in paths (I think), but Rails also encodes it. Apart from that, there are a lot of apps that use these kind of characters. See google, when you search for an image: http://images.google.es/imgres?imgurl=http://www.lightworker.com/album/indexthumbs/alien_hello.gif&imgrefurl=http://profile.myspace.com/index.cfm%3Ffuseaction%3Duser.viewprofile%26friendid%3D76552036&h=300&w=300&sz=50&hl=es&start=3&um=1&tbnid=YRZ9kSX973HXCM:&tbnh=116&tbnw=116&prev=/images%3Fq%3DHello%26um%3D1%26hl%3Des%26sa%3DN after the http://images.google... there is a "imgurl=http://..." I mean, here they also use the character "/", and it is not encoded. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-14 12:57 UTC
Re: "link_to" helper: Looking for no encoding in URLs
My Rails version is 1.2.5. I can reproduce your example programming an "<a href=..." directly, but not with link_to. Link_to always encode my characters. Thorsten Mueller wrote:> Damaris Fuentes wrote: >> I was doing that, but the result of link_to was: >> >> <a href="play_entries/foo%3Dbar"></a> >> > > it worked in my case. > did you copy my example? > > maybe it has to do with the routing and the kind of action. eg my > example worked on the index action, which does not need an id parameter. > your sdrs_query_path (singular path) should call the show action and > therefore expect the id as first parameter. in this case it may handle > things different. > > or there are differences in the rails versions? i simply can''t reproduce > it in the way it works for you...-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 14, 2008, at 13:55 , Damaris Fuentes wrote:> yes, you''re right, and I can try with another character. > The thing is that, for example, the character "|" is not a reserved > character in paths (I think), but Rails also encodes it.In fact I am not 100% sure it is technically a reserved character there. Let me explain. The RFC says you first need to split the URL apart, and then interpret reserved characters _depending on the part of the URL you are dealing with_. My interpretation as far as "=" is concerned is that first you would split the URL by "?" and then interpret "=" in the query string. Since AFAIK there''s no special meaning for "=" to the left of the question mark I think technically it is not required to be escaped. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Feb-14 14:06 UTC
Re: "link_to" helper: Looking for no encoding in URLs
Yes, I thought I wouldn''t have problems cause I am not using the "?", so the "=" sign was not involved in any query variable :( But well... Xavier Noria wrote:> On Feb 14, 2008, at 13:55 , Damaris Fuentes wrote: > >> yes, you''re right, and I can try with another character. >> The thing is that, for example, the character "|" is not a reserved >> character in paths (I think), but Rails also encodes it. > > In fact I am not 100% sure it is technically a reserved character > there. Let me explain. > > The RFC says you first need to split the URL apart, and then interpret > reserved characters _depending on the part of the URL you are dealing > with_. My interpretation as far as "=" is concerned is that first you > would split the URL by "?" and then interpret "=" in the query string. > Since AFAIK there''s no special meaning for "=" to the left of the > question mark I think technically it is not required to be escaped.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---