you are in: codestackercodes [RSS] → tag: seo [RSS]

to_param Delicious Email

http://apidock.com/rails/Object/to_paramhttp://apidock.com/rails/Object/to_param#47-Better-slug-generation-essentially-a-to-param-replacement-

show/hide lines
   1  # create the slugify method
   2    class String
   3      def slugify
   4        returning self.downcase.gsub(/'/, '').gsub(/[^a-z0-9]+/, '-') do |slug|
   5          slug.chop! if slug.last == '-'
   6        end
   7      end
   8    end
   9  
  10  
  11  #####################
  12  # in model
  13    def to_param
  14      "#{id} #{title}".slugify
  15    end
created by leozera — 03 February 2009 — get a short url — tags: rails ruby seo embed