is having controller within controller bad practice?

I've been trying to make my URLs even more search engine friendly lately. I've gotten away from using integer values in the URL for anything except the admin/non-public side of my applications. I've been using a :base_name column combined that with some routing.

In the model I do:

before_save :base_name_from_title

def base_name_from_title   self.base_name = title.downcase.gsub( /\ and\ /, '-' ).     gsub( /\ on\ /, '-' ).     gsub( /[^a-zA-Z0-9\-]/, '-' ).     gsub( /[\-]+/, '-' ).     gsub( /[\-]$/, '' ).     gsub( /^[\-]/, '' ) end

"title" is whatever important wordy field I can pick out of a given model. It's tough to pick sometimes especially if the field isn't unique. I don't have too many collisions on my personal blog though.

Then I add a route:

map.connect "category/:base_name",             :controller => 'category',             :action => 'index',             :requirements => { :base_name => /[\w-]+/ },             :base_name => nil

Then in the controller I look it up by base_name instead of by id:

Category.find( :first, :conditions => [ 'base_name = ?', params[:base_name] ] )

Don't forget to index that text field! :slight_smile:

Then my URLs look like: