Sha256: dbb9c01fa3f5b9cbd2ab362aa8ffe3628bd01fa639ac0b539813f549dbfc7ee0

Contents?: true

Size: 1.5 KB

Versions: 18

Compression:

Stored size: 1.5 KB

Contents

class Category < ActiveRecord::Base
  has_and_belongs_to_many :posts
  has_and_belongs_to_many :special_posts, :class_name => "Post"
  has_and_belongs_to_many :other_posts, :class_name => "Post"
  has_and_belongs_to_many :posts_with_authors_sorted_by_author_id, -> { includes(:authors).order("authors.id") }, :class_name => "Post"

  has_and_belongs_to_many :select_testing_posts,
                          -> { select 'posts.*, 1 as correctness_marker' },
                          :class_name => 'Post',
                          :foreign_key => 'category_id',
                          :association_foreign_key => 'post_id'

  has_and_belongs_to_many :post_with_conditions,
                          -> { where :title => 'Yet Another Testing Title' },
                          :class_name => 'Post'

  has_and_belongs_to_many :popular_grouped_posts, -> { group("posts.type").having("sum(comments.post_id) > 2").includes(:comments) }, :class_name => "Post"
  has_and_belongs_to_many :posts_grouped_by_title, -> { group("title").select("title") }, :class_name => "Post"

  def self.what_are_you
    'a category...'
  end

  has_many :categorizations
  has_many :special_categorizations
  has_many :post_comments, :through => :posts, :source => :comments

  has_many :authors, :through => :categorizations
  has_many :authors_with_select, -> { select 'authors.*, categorizations.post_id' }, :through => :categorizations, :source => :author

  scope :general, -> { where(:name => 'General') }
end

class SpecialCategory < Category
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
ibm_db-5.2.0 test/models/category.rb
ibm_db-5.1.0 test/models/category.rb
ibm_db-5.0.5 test/models/category.rb
ibm_db-5.0.4 test/models/category.rb
ibm_db-5.0.3 test/models/category.rb
ibm_db-5.0.2 test/models/category.rb
ibm_db-4.0.0-x86-mingw32 test/models/category.rb
ibm_db-4.0.0 test/models/category.rb
ibm_db-3.0.4-x86-mingw32 test/models/category.rb
ibm_db-3.0.4 test/models/category.rb
ibm_db-3.0.3-x86-mingw32 test/models/category.rb
ibm_db-3.0.3 test/models/category.rb
ibm_db-3.0.2-x86-mingw32 test/models/category.rb
ibm_db-3.0.2 test/models/category.rb
activejob-lock-0.0.2 rails/activerecord/test/models/category.rb
ibm_db-3.0.1 test/models/category.rb
ibm_db-3.0.1-x86-mingw32 test/models/category.rb
activejob-lock-0.0.1 rails/activerecord/test/models/category.rb