Sha256: d5339e7b773981bc3b069611e4af72f4d260b81c0fb9a4fad3a02036a44e95d7
Contents?: true
Size: 999 Bytes
Versions: 3
Compression:
Stored size: 999 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
unscoped_associations-0.6.5 | spec/support/models.rb |
unscoped_associations-0.6.4 | spec/support/models.rb |
unscoped_associations-0.6.3 | spec/support/models.rb |