search for: generate_slug

Displaying 1 result from an estimated 1 matches for "generate_slug".

2006 Jul 18
2
how to generate calculated db fields
..."page slug" i.e. a url sanitized id from some text in my model that I want to be saved into the database and I''m not seeing how I can do it. The closest I''ve come to getting this to work has been... class Page < ActiveRecord::Base attr :name before_save :generate_slug def generate_slug self.slug = self.name.gsub /\W+/, ''-'' end end ...but this is unsatisfactory as I would like to have the slug generated from the name without having to save to the database. anyone have an idea of the proper Ruby way? Ideally I''d like to b...