
create class level methods such as delete
Reported by jack dempsey (jackdempsey) | April 15th, 2008 @ 09:08 PM
It would be useful to have the ability to make class level calls such as Object.delete(id) rather than Object[id].destroy which will generate two calls to the DB. ActiveRecord has similar methods and would probably be a good basis to look at for some examples of other similar methods.
Comments and changes to this ticket
-
Dan Kubb (dkubb) April 15th, 2008 @ 09:13 PM
- Milestone cleared.
In general I think this is a good idea. However one question we should ask before implementing this is that if we allow a way to delete without checking the associations we could create orphan records.
Since we're going to allow the user to specify the behavior on-delete (like cascade, restrict, etc) we may need to check the associations in some cases. In one case (like restrict) we may be able to do a SELECT COUNT(*) for each association, and allow the delete if all the counts are 0. Cascade is even trickier, but IMHO we need to handle those cases.
-
Dan Kubb (dkubb) April 15th, 2008 @ 09:20 PM
- State changed from new to open
-
Sam Smoot April 27th, 2008 @ 10:57 PM
- State changed from open to invalid
I'm pushing this off... I could go either way on wether it's "right" or "wrong" to support this right now. I don't think it's a blocker for 0.9.0 tho'.
-
jack dempsey (jackdempsey) April 27th, 2008 @ 11:03 PM
Cool...definitely not a blocker, and Dan brings up some good points on how to deal with implementation and things like orphaned records...I think the ability to support it tho, especially as I think there'd be some way to inspect the object (and see what other records might need to be updated, with just the simple class level call) would be valuable.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »