среда, 14 марта 2012 г.

прикольная генерация ЧПУ

http://rubydoc.info/github/norman/friendly_id/master/frames

 

class Post < ActiveRecord::Base
extend FriendlyId  friendly_id :title_or_slug, :use => [:slugged, :history]
scope :published, where(:published=>true) default_scope :order=>"id DESC" validates :title, :presence => true
def should_generate_new_friendly_id?    new_record? || slug == ""  end
def title_or_slug slug = nil if slug == "" slug ? slug : title end def published_class published ? "published" : "unpublished" end  # def normalize_friendly_id(text)  #   text.to_slug.normalize! :transliterations => :russian  # endend

Комментариев нет:

Отправить комментарий