Hi,
How can I retrieve all deleted entries for a has_n relationship?
I have a "Dealer" model. A dealer can have "n" number of coupons ("Coupon"
model). Coupon model has a ParanoidDateTime property.
Doing:
Dealer.first(:id => 30000).coupons.with_deleted
Doesn't work. It gives me all coupons in the database. (Is this a possible
bug?)
Doing:
Dealer.first(:id => 30000).coupons(:deleted_at.not => nil)
Doesn't work. It gives me an empty array. (With and without lazy load on
:deleted_at)
The only way that I can make this to work is by doing the following:
Coupon.with_deleted.all(:dealer_id => 30000) - Coupon.all(:dealer_id =>
30000)
If this is not self explanatory - getting all coupons for a said dealer and
subtracting all currently active coupons.
This is very ugly. Anyone have any ideas?
Thanks for the help!!! :)
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/datamapper/-/izjT3aSaNEYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.