11155
(-- --)
August 28, 2010, 4:07am
1
The path I currently have for a record in the post table is this:
www.myrailsapp.com/post/id
here's the route:
map.resources :posts, :has_many => :comments
Any thoughts on how you would make the above this?
www.myrailsapp.com/1djs34 (or some join of randomly generated letters
and numbers) so that users easily bookmark the page and access it later.
I'd want to replace the traditional path id with something more random.
How would I make an extra column in the post table to do this?
Did some google searching, but I guess I'm not hitting the right
keywords.
Thanks!
The path I currently have for a record in the post table is this:
www.myrailsapp.com/post/id
here's the route:
map.resources :posts, :has_many => :comments
Any thoughts on how you would make the above this?
www.myrailsapp.com/1djs34 (or some join of randomly generated letters
and numbers) so that users easily bookmark the page and access it later.
Why cannot they bookmark page www.myrailsapp.com/post/631 just as
easily as www.../1djs32?
Colin
11155
(-- --)
August 28, 2010, 12:14pm
3
I suppose they could, but I'd like to make the URL path as short as
possible. Plus, it's a excuse to learn how it works :).
Colin Law wrote:
hassan
(Hassan Schroeder)
August 28, 2010, 2:23pm
4
I suppose they could, but I'd like to make the URL path as short as
possible.
Why? What possible value does an obfuscated and shortened URL
offer anyone?
If anything, most users would get more value out of something like
www.myrailsapp.com/post/631-what-were-they-thinking
which at least gives the user (as well as search engines!) *some*
meta-information about the content of the resource...
Plus, it's a excuse to learn how it works :).
..and you could google `rails friendly urls` for implementation examples
to study
FWIW,
11155
(-- --)
August 28, 2010, 2:30pm
5
That is true... I guess what I'm trying to get at is avoid using the
built in ids as the resource identifier... and instead just using a
randomly generated number as the identifier:
www.myrailsapp.com/post/what-were-they-thinking-184952
Hassan Schroeder wrote:
hassan
(Hassan Schroeder)
August 28, 2010, 3:02pm
6
Again, I don't know why you'd bother but you could generate a
separate number on creation and use that -- google 'rails UUID' for
one approach.
HTH,
11155
(-- --)
August 28, 2010, 3:09pm
7
Awesome, thanks Hassan for pointing me in the right direction.
Hassan Schroeder wrote:
hassan
(Hassan Schroeder)
August 28, 2010, 4:39pm
9
Point taken. But I'd still rather see a human/SEO-friendly URL in my
browser and as appropriate provide a "tweetable" version on the page