Sha256: 5c302cfb8fbcbcb241c04fe0baf1b0f016855e7442793266c20e2a498f34a665
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
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 if ActiveRecord::VERSION::MAJOR >= 4 has_one :last_comment, -> { order('created_at DESC') }, class_name: 'Comment' has_one :unscoped_last_comment, -> { order('created_at DESC') }, class_name: 'Comment', unscoped: true else has_one :last_comment, class_name: 'Comment', order: ('created_at DESC') has_one :unscoped_last_comment, class_name: 'Comment', unscoped: true, order: ('created_at DESC') end has_many :votes, as: :votable, 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 has_many :votes, as: :votable default_scope { where(public: true) } end class Vote < ActiveRecord::Base belongs_to :votable, polymorphic: true, unscoped: true default_scope { where(public: true) } end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unscoped_associations-0.7.1 | spec/support/models.rb |
unscoped_associations-0.7.0 | spec/support/models.rb |