我在使用Rails正確工作時遇到了一些麻煩。如何在Rails 3中查找相關記錄
我的模型:
class User < ActiveRecord::Base
default_scope :conditions => 'users.deleted_at IS NULL'
class Feed < ActiveRecord::Base
belongs_to :user, :foreign_key => :author_id
當我撥打以下:
feeds = Feed.includes(:user)
我想跳過了用戶的default_scope。所以我嘗試過:
feeds = Feed.unscoped.includes(:user)
但是,這並不是從用戶中刪除範圍。關於如何讓這個工作的任何建議?謝謝
http://stackoverflow.com/questions/3963124/default -scope-and-associations或http://stackoverflow.com/questions/4758145/how-to-use-unscoped-on-associated-relations-in-rails3幫助? –
可悲的是,沒有。第一個已經過時了。第二個不詳細使用包括。 – AnApprentice