Sha256: dc1c0fc9aa7c6dbb90ad0be0a30ba3d9d6673acbe7ddaeb5e2bf5e30e456103c

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

class User < ActiveRecord::Base
  has_many :comments
  has_many :unscoped_comments, class_name: 'Comment', unscoped: true
  has_one  :last_comment, class_name: 'Comment', order: 'created_at DESC'
  has_one  :unscoped_last_comment, class_name: 'Comment', order: 'created_at DESC', unscoped: true

  default_scope { where(active: true) }
end

class Comment < ActiveRecord::Base
  belongs_to :user
  belongs_to :scoped_user, class_name: 'User', foreign_key: 'user_id', unscoped: false
  belongs_to :unscoped_user, class_name: 'User', foreign_key: 'user_id', unscoped: true

  default_scope { where(public: true) }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unscoped_associations-0.6.1 spec/support/models.rb
unscoped_associations-0.6.0 spec/support/models.rb