Tomasz Romanowski
2010-Aug-06 17:52 UTC
restful URLs fail to generate when id is not numeric
I''m trying to work with an existing Oracle schema which of course does not follow the Rails conventions for table/column names or primary key types. I used Scaffold to get everything going. I got the table name and the column names set up and I can retrieve the records correctly. However I cannot get the RESTful URLs to work, for Show or Edit. I nailed it down to the issue with the identifier not being numeric. When I update the primary key column - which is VARCHAR2(32) - to contain integers then all URL issues disappear and I am able to Show, Edit and Update. But when I fall back the original values I get "XXX_url failed to generate..." errors. Any ideas how to get around this? Tom -- 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-/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.
Hassan Schroeder
2010-Aug-06 18:07 UTC
Re: restful URLs fail to generate when id is not numeric
On Fri, Aug 6, 2010 at 10:52 AM, Tomasz Romanowski <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to work with an existing Oracle schema which of course does > not follow the Rails conventions for table/column names or primary key > types. I used Scaffold to get everything going. I got the table name and > the column names set up and I can retrieve the records correctly. > However I cannot get the RESTful URLs to work, for Show or Edit. I > nailed it down to the issue with the identifier not being numeric. When > I update the primary key column - which is VARCHAR2(32) - to contain > integers then all URL issues disappear and I am able to Show, Edit and > Update. But when I fall back the original values I get "XXX_url failed > to generate..." errors.Without any code, it''s hard to say. However, I have a legacy DB I''m working with that has an alphanumeric primary key, where the model includes: set_primary_key "product" # e.g. "E70211A" and this link generates an appropriate path: <%= link_to product.product_name, product_path(product.product) %> HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.
Robert Walker
2010-Aug-06 19:50 UTC
Re: restful URLs fail to generate when id is not numeric
Tomasz Romanowski wrote:> I''m trying to work with an existing Oracle schema which of course does > not follow the Rails conventions for table/column names or primary key > types. I used Scaffold to get everything going. I got the table name and > the column names set up and I can retrieve the records correctly. > However I cannot get the RESTful URLs to work, for Show or Edit. I > nailed it down to the issue with the identifier not being numeric. When > I update the primary key column - which is VARCHAR2(32) - to contain > integers then all URL issues disappear and I am able to Show, Edit and > Update. But when I fall back the original values I get "XXX_url failed > to generate..." errors. Any ideas how to get around this? > TomIs it possible that you''re existing primary key values will need to be URL escaped in order to produce valid URLs? Do they contain spaces or other special characters that are not permitted in URLs? -- 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-/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.
Robert Walker
2010-Aug-06 19:52 UTC
Re: restful URLs fail to generate when id is not numeric
BTW for those that follow my posts, I''m actually not completely daft on the use of your vs. you''re, and its vs. it''s. I guess my fingers are when typing into this forum though. Grrr. I drive myself nuts with that sometimes. hehe. -- 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-/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.
Tomasz Romanowski
2010-Aug-07 00:30 UTC
Re: restful URLs fail to generate when id is not numeric
> Is it possible that you''re existing primary key values will need to be > URL escaped in order to produce valid URLs? Do they contain spaces or > other special characters that are not permitted in URLs?Yup! Thanks! That''s what it was! I had a few entries formatted like: XXX.DEFAULT.USER.834029834092830 I changed the primary key and it worked. Will figure out later how to handle it long-term. Robert Walker wrote:> Tomasz Romanowski wrote: >> I''m trying to work with an existing Oracle schema which of course does >> not follow the Rails conventions for table/column names or primary key >> types. I used Scaffold to get everything going. I got the table name and >> the column names set up and I can retrieve the records correctly. >> However I cannot get the RESTful URLs to work, for Show or Edit. I >> nailed it down to the issue with the identifier not being numeric. When >> I update the primary key column - which is VARCHAR2(32) - to contain >> integers then all URL issues disappear and I am able to Show, Edit and >> Update. But when I fall back the original values I get "XXX_url failed >> to generate..." errors. Any ideas how to get around this? >> Tom > > Is it possible that you''re existing primary key values will need to be > URL escaped in order to produce valid URLs? Do they contain spaces or > other special characters that are not permitted in URLs?-- 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-/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.