Sha256: afb0b6c3d9e69ca86216ec51fb27c1f8865e93babbd2852a898c1f548e687478

Contents?: true

Size: 515 Bytes

Versions: 1

Compression:

Stored size: 515 Bytes

Contents

class CommunityCategory < ActiveRecord::Base
  extend FriendlyId
  
  belongs_to :community
  
  has_many :community_category_feedbacks, source: 'category'
  has_many :feedbacks, through: :community_category_feedbacks
  
  validates :community_id, presence: true
  validates :name, presence: true, uniqueness: { scope: :community_id }
  
  friendly_id :name, use: :scoped, scope: :community
  
  attr_accessible :name
  
  private
  
  def should_generate_new_friendly_id?
    slug.blank? || name_changed?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary_feedback-0.1.0 app/models/community_category.rb