Modification of the to_param method in the Model is really required / convenient, like the others already said:
def to_param pagename.parameterize end
But in order to find messages, you also need to change the controller, since the Post.find methods by default look for the identifier, not pagename. For the show action, you need something like this:
def show @post = Post.where(:pagename => params[:id]).first end
The same applies to other methods of action.
Routing rules can remain the same as for regular routes with an identification number.
Veger source share