Reputation: 2933
In some cases, I would like to specify that my ActiveRecord results should include items where deleted_at is not null.
For example, say I search for the following deleted record:
item =Item.find(12345)
I get this result:
ActiveRecord::RecordNotFound: Couldn't find Item with id=12345 [WHERE ("items"."deleted_at" IS NULL)]
Is it possible to set a parameter that returns active record items where the deleted_at value is not null?
Upvotes: 2
Views: 3033
Reputation: 1400
You can disable all scopes by applying 'unscoped' method to your model, like:
item = Item.unscoped.find(12345)
http://guides.rubyonrails.org/active_record_querying.html#removing-all-scoping
Upvotes: 6