Every repository with this icon (
Every repository with this icon (
| Description: | DEFUNCT: ActiveRecord 2.3 compatible gem "allowing you to hide and restore records without actually deleting them." Yes, like acts_as_paranoid, only implemented differently... edit |
-
You can specify a default scope beneath your is_paranoid line, but you'll need to include the is_paranoid conditions, i.e.: defaut_scope :deleted_at => nil, :order => 'created_at DESC'. However this isn't ideal as the places in the code that use with_exclusive_scope to ignore the is_paranoid conditions will also ignore your conditions.
It would be nice to have an easy way to merge these things that only breaks out of the is_paranoid scope on the with_destroyed (etc.) methods, but it is rather complicated given the aforementioned issue, so it may be awhile.
Feel free to implement this well and send a pull request :)
Comments
-
3 comments Created 7 months ago by semanticartproblem with nested attributes and is_paranoidwaitingxreported by drawohara "pro tip: nested_attributes and is_paranoid get into a pissing contest and blow your application up."
"try to delete an associated object via the _delete methodology that nested_attributes employs"Comments
semanticart
Sat May 16 10:03:42 -0700 2009
| link
I've created a sample app here: http://github.com/jchupp/is_paranoid_nested_attributes_test/tree/master and punted back to drawohara to attempt to reproduce it
binarylogic
Fri Jul 17 14:42:27 -0700 2009
| link
You couldn't reproduce the problem in your sample app?
semanticart
Sun Jul 19 15:09:30 -0700 2009
| link
I could not. And drawohara didn't get back to me on it. I'd love to close this if someone else will confirm that they can't replicate it.
-
You can only soft delete a model with its association with model.destory.
But If you want to fully delete a model, you can only do model.delete - but that doesn't include the associations....!
So no way is possible to destroy a model with its association cleanly.
Comments
semanticart
Thu Jul 30 14:42:04 -0700 2009
| link
I can see why you might want to do this, but it looks like a fringe use case. I'll give this some though and if I come up with a quick fix, I'll see what I can do.
However, I'm super busy, so I wouldn't recommend holding your breath. If you want to get your hands dirty with the code, I'll gladly entertain a pull request. Good luck :)
-
Hello
Using latest gem, is_paranoid gives 2 issues. While the first is minor, the second is critical:
1/ using named_scopes add to the SQL query as many "deleted_at IS NULL" as they are chaining named scopes. This is dirty :(
ex:
User.all # SELECT FROM "users" WHERE ("users"."deleted_at" IS NULL)
User.senior.registered.all # SELECT FROM "users" WHERE ((("users"."deleted_at" IS NULL) AND ("users"."age" > 60)) AND (("users"."deleted_at" IS NULL AND ("users"."registered" = 1))) AND ("users"."deleted_at" IS NULL))2/ Using the find/count_with_destroyed simply removes all named scopes you may add and chain since the method uses with_exclusive_scope block.
So User.senior.registered.all_with_destroyed does only query SELECT * FROM "users" !!Is it fixable ?
Best
Comments
semanticart
Fri Sep 04 16:47:59 -0700 2009
| link
semanticart
Fri Sep 04 16:57:33 -0700 2009
| link
To add to that comment, I should be able to push a fix this weekend. Stay tuned
semanticart
Mon Sep 07 08:17:49 -0700 2009
| link
I'm going to back-pedal on this. Unfortunately there's no good way to "undo" scopes with ActiveRecord. Basically the default_scope (is_paranoid) gets mashed into your named scope (in this case, "senior") and ends up just being string. So removing it is somewhat complicated.
I'm going to keep looking into this, but, to be frank, I just don't use the xxx_with_destroyed methods with named_scopes (I generally just ignore anything that's deleted unless I'm doing statistics or purging old records, etc.), so I'm not heavily personally motivated. If its your itch, though, please scratch it and fork away. I'd love to pull in a fix.
I understand your lazyless :P
I almost found a workaround but I'm a bit blocked. I don't want to undo with AR, just not do: I was thinking about removing the default scope and defining 3 named scopes: :without_deleted, :with_deleted and :only_deleted. Then wrapping the find method, check if :with_deleted or :only_deleted scopes are applied, and apply :without_deleted if none of these 2 scopes are already sent. Unfortunately, the #scopes method only returns which scopes are already available for the class and not which ones are already applied to the AR instance. Keeping with_destroyed methods is piece of cake of course for backward compatibility (we can also add with_deleted for the technoweenie legacy). That would be the trick. What do you think ?
semanticart
Mon Sep 07 09:29:02 -0700 2009
| link
I think that could definitely work. If you can fork it and pass the specs plus add a spec covering named scopes working in the with_destroyed, etc. instances, I'll almost certainly merge it.
In regards to the sql conditions being doubled up, I'm not yet sure where that's occurring (I did try to recreate it but failed). What DBMS are you using? can you provide a spec that exhibits this behavior?
SCOPES: ok first I need to learn rspec :p, next I can fork and write what I have in mind but only if you know how to get the list of named scopes a model instance has ! Do you ?
SQL: I'm using postgresql, but I do experience the same issue with a blank sqlite app.
semanticart
Mon Sep 07 13:04:53 -0700 2009
| link
ModelName.scopes will return a list.
Yes, that's what I wrote in a previous message. But it's a class method returning available named scopes, not an instance method returning applied named scopes.
semanticart
Mon Sep 07 15:45:15 -0700 2009
| link
yeah, and you'll probably agree that this is why it isn't easy.
you can use #current_scoped_methods which is the currently applied scope, or #scoped_methods which returns an array of applies scopes. However, those aren't nice symbols or anything of the sort, it is a flattened set of conditions, etc.
Example: [{:find=>{:conditions=>{:deleted_at=>nil}}, :create=>{:deleted_at=>nil}}, {:find=>{:conditions=>"("androids"."deleted_at" IS NULL) AND (name like '%C%')"}, :create=>{:deleted_at=>nil}}]
so, not much nice to work with
-
Hi again, I get this on an heroku server, but not on my local server. Strange. Any ideas on this?
SystemStackError (stack level too deep):
/home/slugs/65132_add5f21_bcf4/mnt/.gems/gems/steipete_is_paranoid-0.9.6/lib/is_paranoid.rb:203:inold_method_missing' /home/slugs/65132_add5f21_bcf4/mnt/.gems/gems/steipete_is_paranoid-0.9.6/lib/is_paranoid.rb:239:inmethod_missing' app/models/testcase.rb:75:inadapt_from_version' app/models/testcase.rb:65:inset_to_version' app/models/tc_link.rb:56:intestcase' app/models/tc_link.rb:33:inestimated_time'Comments
-
0.9.6 doesn't play nice with acts_as_taggable_on
1 comment Created 2 months ago by inciteHi,
When using 0.9.6 with mbleigh-acts-as-taggable-on (latest gem), I get these kinds of issues:
ActiveRecord::StatementInvalid in 'Ticket before(:all)'
PGError: ERROR: column taggings.deleted_at does not exist
LINE 1: ...AND ("taggings".taggable_type = E'Ticket') AND (((taggings.d...
^: SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags".id = "taggings".tag_id WHERE (("taggings".taggable_id = 1) AND ("taggings".taggable_type = E'Ticket') AND (((taggings.deleted_at IS NULL))) AND (context = E'tags')) ./spec/models/ticket_spec.rb:16:
I'm thinking it's an issue w/ is_paranoid, not acts_as_taggable_on - sorry if I'm wrong.
Comments
semanticart
Fri Oct 16 05:47:25 -0700 2009
| link
it definitely could be. As i've noted in the readme and repo description, though, this library is defunct. I'll leave this open for other people to be aware of (and maybe offer solutions) but i can't promise it will be fixed.
good luck












joshua clayton provides a solution here: http://joshuaclayton.github.com/code/default_scope/activerecord/is_paranoid/multiple-default-scopes.html
I'm still working on a permanent solution (see the comments)