You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
First of all, thank you for this amazing gem, it has helped me ALOT.
So, I'm trying to retrieve the soft-deleted belongs_to record without using with_deleted for the belongs_to association, as it would disturb the normal flow of the associations used elsewhere in the app.
Here's what I'm trying to do:
class Leave < ApplicationRecord
acts_as_paranoid
belongs_to :user
end
class User < ApplicationRecord
acts_as_paranoid
has_many :leaves, dependent: :destroy
end
I'm trying to retrieve the deleted User, from the deleted Leave like so:
Leave.with_deleted.find(1).user.with_deleted
Expected Behavior
Retrieve the deleted user for the deleted leave.
Actual Behavior
Getting error: `undefined method `with_deleted' for nil:NilClass`
Though, I'm able to retrieve the deleted leave.
Configuration
Ubuntu 20.04 Rails 5.1.7 Ruby 2.5.7
Please guide me on what I'm doing wrong.
Thanks 🙂
The text was updated successfully, but these errors were encountered:
Hi!
First of all, thank you for this amazing gem, it has helped me ALOT.
So, I'm trying to retrieve the soft-deleted belongs_to record without using
with_deleted
for the belongs_to association, as it would disturb the normal flow of the associations used elsewhere in the app.Here's what I'm trying to do:
I'm trying to retrieve the deleted User, from the deleted Leave like so:
Expected Behavior
Actual Behavior
Though, I'm able to retrieve the deleted leave.
Configuration
Ubuntu 20.04
Rails 5.1.7
Ruby 2.5.7
Please guide me on what I'm doing wrong.
Thanks 🙂
The text was updated successfully, but these errors were encountered: