我在使用范围在rails中正常工作时遇到了一些麻烦.
我的模特:
class User < ActiveRecord::Base
default_scope :conditions => 'users.deleted_at IS NULL'
class Feed < ActiveRecord::Base
belongs_to :user, :foreign_key => :author_id
Run Code Online (Sandbox Code Playgroud)
当我打电话给以下人时:
feeds = Feed.includes(:user)
Run Code Online (Sandbox Code Playgroud)
我想为用户跳过default_scope.所以我试过了:
feeds = Feed.unscoped.includes(:user)
Run Code Online (Sandbox Code Playgroud)
但这并不是要从用户那里删除范围.有关如何使其工作的任何建议?谢谢