to_param still works with RESTful routes!

Jan 16 by Andre
Just a friendly reminder, the to_param trick still works with RESTful routes. This will still give your Post class a nice "ID + title" URL:
class Post < ActiveRecord::Base
  has_many :comments
 
  def to_param
    "#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}"
  end
end

Post a comment

 
This is so filters can reject the spam-bots. Thanks!