upmin / upmin-admin-ruby

Framework for creating powerful admin backends with minimal effort in Ruby on Rails.
MIT License
757 stars 66 forks source link

upmin doesn't play particularly well with the paranoia gem #176

Open apurvis opened 8 years ago

apurvis commented 8 years ago

If I use upmin to update a user's deleted_at, i get an error as soon as i save the record because the paranoia gem prevents the record from being found.

Then there is the matter that the deleted record can't be found through upmin at all... and the main reason I ended up using upmin in the first place was because I was hoping to give some less than technically savvy people a way to undo record deletion by manually removing deleted_at values from records.

Definitely not a bug but would be a nice option - to be able to even view and edit records that have deleted_at IS NOT NULL

I can't seem to label this issue but it's definitely an enhancement request and not a bug.

mbrookes commented 8 years ago

Looking at the paranoia docs, I'm not seeing anay stragforward wy to achieve this within Upmin, and it's also quite specifc to this particular soft-delete gem, so possibly out of scope.

If you want to give it a go local to your project, you could try cloning: https://github.com/upmin/upmin-admin-ruby/blob/master/app/controllers/upmin/models_controller.rb into your Rails app (see customization in the wiki for details), and change the relevant actions to chain paranoia's .with_deleted method.

This would apply to all models though, and not sure how paranoia behaves for models without a deleted_at column. (ideally it should pass the request though as .all or whatever).

Let us know how it goes!

Edit: Also, if you get to the point where you can successfully find a deleted record, you will be able to customise the view to add an undelete button for deleted records.