Sha256: 82cc55517b249e925c9ad17051dcdda1c367aa97bea1c3b4f161fa2d7eb9a907
Contents?: true
Size: 783 Bytes
Versions: 1
Compression:
Stored size: 783 Bytes
Contents
class User < ActiveRecord::Base has_many :comments do def today where('created_at <= ?', Time.now.end_of_day) end end has_many :unscoped_comments, class_name: 'Comment', unscoped: true do def today where('created_at <= ?', Time.now.end_of_day) end end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unscoped_associations-0.6.2 | spec/support/models.rb |