Sha256: a817d473f8d724d7c84d094f9e5a4c0fa69add9fc92c649e2652c8fb763be101

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

module SimpleForum
  class Category < ::ActiveRecord::Base
    has_many :forums,
             :order => "#{SimpleForum::Forum.quoted_table_name}.position ASC",
             :dependent => :nullify,
             :class_name => "SimpleForum::Forum"


    scope :default_order, order("#{quoted_table_name}.position ASC")

    validates :name, :presence => true
    validates :position, :presence => true, :numericality => {:only_integer => true, :allow_nil => true}

    attr_accessible :name, :body, :position

    if respond_to?(:has_friendly_id)
      has_friendly_id :name, :use_slug => true, :approximate_ascii => true
    else
      def to_param
        "#{id}-#{name.to_s.parameterize}"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_forum-0.0.4 app/models/simple_forum/category.rb
simple_forum-0.0.2 app/models/simple_forum/category.rb