Sha256: 91e198838cc04d897e3cdaff68a490f1ebb753f8f7c50594663e025bcd1455f5

Contents?: true

Size: 885 Bytes

Versions: 7

Compression:

Stored size: 885 Bytes

Contents

module Ems
  class Channel < ActiveRecord::Base
    extend FriendlyId
    friendly_id :name, use: :slugged
    # Validators
    validates_uniqueness_of :slug
    validates :slug, :presence => true
    validates :name, :presence => true

    has_and_belongs_to_many :categories, :join_table => 'ems_categories_channels'
    accepts_nested_attributes_for :categories
    
    has_and_belongs_to_many :articles, :join_table => 'ems_articles_channels'
    accepts_nested_attributes_for :articles
    has_and_belongs_to_many :news, :join_table => 'ems_channels_news'
    accepts_nested_attributes_for :news
    has_and_belongs_to_many :reports, :join_table => 'ems_channels_reports'
    accepts_nested_attributes_for :reports


    #
    # @param options
    def as_json(options={})
      super( options.merge( :include => [ :categories, :articles, :reports, :news ] ) )
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ems-0.0.8 app/models/ems/channel.rb
ems-0.0.7 app/models/ems/channel.rb
ems-0.0.6 app/models/ems/channel.rb
ems-0.0.5 app/models/ems/channel.rb
ems-0.0.4 app/models/ems/channel.rb
ems-0.0.3 app/models/ems/channel.rb
ems-0.0.2 app/models/ems/channel.rb