Sha256: 44b9d40321ee0865e49d7ad73f2ba05fcb1ef694ab4e73507da8e626b551a438
Contents?: true
Size: 494 Bytes
Versions: 6
Compression:
Stored size: 494 Bytes
Contents
class Post < ActiveRecord::Base belongs_to :category, class_name: "PostCategory", counter_cache: true before_save :populate_name def populate_name self.name = self.title.to_s.downcase.gsub(/[^\w\s\d\_\-]/,'').gsub(/\s\s+/,' ').gsub(/[^\w\d]/, '-') end acts_as_routable \ controller_action: "blog#show", prefix: :by_category, suffix: -> { :category_name } acts_as_routable :archive def category_name self.category.try(:name) || 'general' end end
Version data entries
6 entries across 6 versions & 1 rubygems