Sha256: a43024a1a46784ef78dd5c6eb55d83f19b46235906920616c6e29fb1b8d94646

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

class PageModuleCollection < ActiveRecord::Base
  has_many :page_module_collection_modules, dependent: :destroy, foreign_key: 'collection_id'
  has_many :modules, class_name: 'PageModule', through: :page_module_collection_modules
  
  validates :title, presence: true, uniqueness: true
  
  attr_accessible :title
  
  extend FriendlyId
  
  friendly_id :title, use: :slugged  
  
  before_save :set_slug_stub
  
  private
  
  def set_slug_stub
    self.slug_stub = slug.split('-').first
  end
  
  def should_generate_new_friendly_id?
    title_changed?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
home_page-0.0.6 app/models/page_module_collection.rb