I am trying to do the following in a RESTful manner: I have a web service that accepts an id to deliver a particular record. Unfortunately, the id that the client will have is not the usual database sequence number. This mostly works, though, and the url looks something like: http://myservice.com/controller/the_id.xml That is handled by the "show" action. Unfortunately, some of the ids that will be passed contain special characters. I can require that they be encrypted, but the period seems to be having a problem. In other words, if the id is "the+id. value", the url should be: http://myservice.com/controller/the%2bid%2e+value.xml where the plus, period and space are transformed. This works for the plus and space, but the period causes the rest of url to be considered the "format" parameter. Actually, mostly. I''ve tried on two different servers, running the same version of rails. One accepts the above url and one doesn''t. I''ve tried to figure out what is different about the servers. Could this be caused by an Apache configuration difference? Or a Passenger difference? I could use a hint about where the transformation of the %2e to period takes place. --- Alternately, what do you do in this situation? It would be trivial to do this non-RESTfully, by making a custom route, but I was attempting to be completely RESTful in my web service. Am I just making it hard on myself? -- 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.
Michael Pavling
2011-May-23 21:38 UTC
Re: Passing a period as part of an id in show action
On 23 May 2011 21:42, paulie <paul-mzPrHiy5csbYtjvyW6yDsg@public.gmane.org> wrote:> I am trying to do the following in a RESTful manner: > > http://myservice.com/controller/the%2bid%2e+value.xml > > the period causes the rest of url to be considered > the "format" parameter.Can you change your route, rather than controller/id.format can you have: controller/id/format This way it wouldn''t matter if there are full stops in the id (although slashes may become a problem :-) -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2011-May-23 21:53 UTC
Re: Passing a period as part of an id in show action
>> I am trying to do the following in a RESTful manner: >> >> http://myservice.com/controller/the%2bid%2e+value.xml >> >> the period causes the rest of url to be considered >> the "format" parameter. > > Can you change your route, rather than > controller/id.format > can you have: > controller/id/format > This way it wouldn''t matter if there are full stops in the id > (although slashes may become a problem :-)Or tell Rails periods are okay... using a regex... something like... :requirements => { :id => %r([\w.]+) } -- 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.
Thanks for the suggestions. I decided to just go the easy way and have that one entry point not be RESTful. It will look like: http://myservice.com/controller/get?uri=XXXX and: http://myservice.com/controller/get.xml?uri=XXXX On Mon, May 23, 2011 at 5:53 PM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote:>>> I am trying to do the following in a RESTful manner: >>> >>> http://myservice.com/controller/the%2bid%2e+value.xml >>> >>> the period causes the rest of url to be considered >>> the "format" parameter. >> >> Can you change your route, rather than >> controller/id.format >> can you have: >> controller/id/format >> This way it wouldn''t matter if there are full stops in the id >> (although slashes may become a problem :-) > > Or tell Rails periods are okay... using a regex... something like... > > :requirements => { :id => %r([\w.]+) } >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.