Opinions on catch-all routing?


#1

I remember reading somewhere a tip on improving your search engine
ranking, by forming URLs that included relevant text, e.g.
www.domain.com/article/man_eats_hat. In the rails app that I’m writing,
I’ve noticed I can set this up very easily by appending the post title
(after downcase.split.join(’_’)) to the post link. So, blog.com/posts/4
can easily also be blog.com/posts/4/title_of_blog, with the following
added to config/routes.rb:

map.connect ‘:controller/:action/:id/*anything’

Of course this also means that blog.com/posts/4/anything_else points to
the same place, and I was wondering if this could be considered as bad
practice.

Any thoughts?


#2

map.connect ‘:controller/:action/:id/*anything’

Of course this also means that blog.com/posts/4/anything_else points to
the same place, and I was wondering if this could be considered as bad
practice.
You could just have a url version of your blog title in the db. You can
then just have your urls like this:
/posts/my_blog_title/ rather than including the id.

I’ve written a plugin called ‘url_column’ that will maintain a url in
the table from a specified column automatically on saves and updates.

For example, you can do:

class Post < ActiveRecord::Base
url_column :post_url, :from => :title
end

Whenever you save or create a post it’ll automatically ‘urlify’ the post
title and update the post_url column.

If you’re interested, i’ll post it up somewhere.

Hope that helps!

Steve


#3

On 6/9/06, Stephen B. removed_email_address@domain.invalid wrote:

the table from a specified column automatically on saves and updates.
If you’re interested, i’ll post it up somewhere.

Hope that helps!

Please post it. That sounds interesting.


#4

On 6/19/06, Stephen B. removed_email_address@domain.invalid wrote:

This is a very ‘new’ plugin so do have a play and let me know the
results.

Oh and if it’s deemed worthy, i’d like to find a nicer place for it to
live - my blog is not really a great advert for a ‘nice url’ plugin.

Very cool. Thanks for sharing this.


#5

Hi Stephen,

Very nice. My only suggestion would be to call it
permalink_column instead of url_column.

Brent

— Stephen B. removed_email_address@domain.invalid wrote:

Hey All,

I’ve just packaged up a small plugin i wrote to
manage nice urls from a
model attribute.

It’s available for download here:

http://www.2404.co.uk/index.php?path=articles/view.php&articleId=23

nicer place for it to
Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


#6

Hey All,

I’ve just packaged up a small plugin i wrote to manage nice urls from a
model attribute.

It’s available for download here:
http://www.2404.co.uk/index.php?path=articles/view.php&articleId=23

I can only apologise in advance for my dodgy blog - don’t let the
horrible url and php scare you off :0)

This is a very ‘new’ plugin so do have a play and let me know the
results.

Oh and if it’s deemed worthy, i’d like to find a nicer place for it to
live - my blog is not really a great advert for a ‘nice url’ plugin.

Cheers!

Steve


#7

Very nice. My only suggestion would be to call it
permalink_column instead of url_column.
Hmm… good sugguestion - but it’s not really specifically for permenant
links. It’ll will be updated if, say, the title of the page changes.

In that respect it can be used for categories, pages, products -
whatever.

Steve


#8

On Jun 19, 2006, at 16:37, Stephen B. wrote:

horrible url and php scare you off :0)

This is a very ‘new’ plugin so do have a play and let me know the
results.

Oh and if it’s deemed worthy, i’d like to find a nicer place for it to
live - my blog is not really a great advert for a ‘nice url’ plugin.

Nice! Does it handle non-ASCII in UTF-8?

– fxn


#9

Posted at http://agilewebdevelopment.com/plugins/url_column :slight_smile:


Benjamin C.
http://www.bencurtis.com/
http://www.tesly.com/ – Collaborative test case management
http://www.agilewebdevelopment.com/ – Resources for the Rails community


#10

Nice! Does it handle non-ASCII in UTF-8?
It uses basic Ruby replaces. I’ve not really tried it with anything
more complex than the examples and tests - try it out and let me know
:0)

Steve