Forum: Ruby on Rails Opinions on catch-all routing?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David E. (Guest)
on 2006-06-09 16:03
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?
Stephen B. (Guest)
on 2006-06-09 19:43
> 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
Wilson B. (Guest)
on 2006-06-09 23:20
(Received via mailing list)
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.
Stephen B. (Guest)
on 2006-06-19 18:37
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...

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
Wilson B. (Guest)
on 2006-06-19 18:44
(Received via mailing list)
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.
Brent Beardsley (Guest)
on 2006-06-19 19:00
(Received via mailing list)
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...
> 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
Xavier N. (Guest)
on 2006-06-19 19:12
(Received via mailing list)
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
Stephen B. (Guest)
on 2006-06-19 19:14
> 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
Stephen B. (Guest)
on 2006-06-19 19:25
> 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
Benjamin C. (Guest)
on 2006-06-20 13:27
(Received via mailing list)
Posted at http://agilewebdevelopment.com/plugins/url_column :)

--
Benjamin C.
http://www.bencurtis.com/
http://www.tesly.com/ -- Collaborative test case management
http://www.agilewebdevelopment.com/ -- Resources for the Rails community
This topic is locked and can not be replied to.