Sha256: c1eeef7689bc565582ff101ef1eb6f87e4283343a43117cd104244537389071e

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

ActiveRecord::Migration.verbose = false
ActiveRecord::Base.establish_connection(:adapter  => 'sqlite3', :database => ':memory:')

class CreateModelsForTest < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string     :name
      t.integer    :posts_count, :default => 0
      t.integer    :comments_count, :default => 0
    end
    create_table :posts do |t|
      t.string     :body
      t.belongs_to :user
      t.integer    :count_of_comments, :default => 0
    end
    create_table :comments do |t|
      t.string     :body
      t.belongs_to :user
      t.belongs_to :post
    end
  end
  def self.down
    drop_table(:users)
    drop_table(:posts)
    drop_table(:comments)
  end
end

class User < ActiveRecord::Base
  has_many :comments
  has_many :posts
end

class Post < ActiveRecord::Base
  belongs_to :user, :async_counter_cache => true
  has_many :comments
end

class Comment < ActiveRecord::Base
  belongs_to :user, :async_counter_cache => true
  belongs_to :post, :async_counter_cache => "count_of_comments"
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
ar-resque-counter-cache-3.0.1 spec/models.rb
ar-resque-counter-cache-3.0.0 spec/models.rb
ar-resque-counter-cache-3.0.0.rc1 spec/models.rb
ar-resque-counter-cache-2.1.0 spec/models.rb
ar-resque-counter-cache-2.0.3 spec/models.rb
ar-resque-counter-cache-2.0.2 spec/models.rb
ar-resque-counter-cache-1.0.2 spec/models.rb
ar-resque-counter-cache-2.0.1 spec/models.rb
ar-resque-counter-cache-1.0.1 spec/models.rb
ar-resque-counter-cache-2.0.0 spec/models.rb
ar-resque-counter-cache-1.0.0 spec/models.rb
ar-resque-counter-cache-0.0.2 spec/models.rb
ar-resque-counter-cache-0.0.1 spec/models.rb
ar-async-counter-cache-0.1.2 spec/models.rb
ar-async-counter-cache-0.1.1 spec/models.rb
ar-async-counter-cache-0.0.3 spec/models.rb
ar-async-counter-cache-0.0.2 spec/models.rb
ar-async-counter-cache-0.0.1 spec/models.rb