Sha256: 900fb37c56d20673e2b4477f3efa87611a184681ac358ae60f583912bb7a4711

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

module SimpleForum
  class Category < ::ActiveRecord::Base

    set_table_name 'simple_forum_categories' #should work table_name_prefix in SimpleForum module but it's not!'

    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

1 entries across 1 versions & 1 rubygems

Version Path
simple_forum-0.0.1 app/models/simple_forum/category.rb