Acts_as_paranoid, is_paranoid... Alternatives? - ruby-on-rails

I'm looking for a rails plugin/gem which brings the functionality of marking an ActiveRecord-Model deleted, instead of deleteing it.
Does anybody know, what gems or plugins are up to date? (AAP is out-dated and is_paranoid doesn't appear to be used by the community).
Do you know alternatives?

It seems even the authors of both acts_as_paranoid and is_paranoid aren't using their respective plugins/gems any more. Both are using named scopes.
Yeah, it's not automagic or anything, but sometimes being explicit about your intentions is a good thing.

For completeness, here is a more recent gem for this purpose:
Paranoia - acts_as_paranoid for Rails 3
https://github.com/radar/paranoia
And another:
https://github.com/JackDanger/permanent_records

is_paranoid doesn't appear to be used by the community..
http://chadfowler.com/blog/2009/07/08/how-ruby-mixins-work-with-inheritance/ - Just a blog post the other day talking about it. Seems like it solved Chad's problem just fine (as well as lead him to write a post about inheritance and mixins).

How about you just have a valid:boolean column/attribute and set it to false when you wish to soft-delete the model? Or am I missing something?

Related

Migrating from acts_as_paranoid to paranoia gem

We have used acts_as_paranoid gem(https://github.com/ActsAsParanoid/acts_as_paranoid) for soft deletion in our project. The project is in live now. Faced some of the issues in this gem and planned to migrate to paranoia gem(https://github.com/rubysherpas/paranoia). Is there anything we need to consider while migrating?
I would recommend taking a look at Discard
https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid
It accomplishes a similar goal without overriding activerecord's method by taking a simpler approach of providing convenience methods to hide soft-deleted records. There is a section on the documentation about why the author thiks this is better than either acts-as-paranoid or paranoia.

Rails plugin for showing lists/index pages

I'm looking for a Rails plugin that facilitates showing lists of objects. Ideally I'd like to pass an ActiveRecord query and get a table that shows a result of this query. The table should be sortable, paginated and searchable (using some kind of filters).
I've already found two that might be ok. The first is DataGrid. It looks fine, but it uses will-paginate and as I adopted kaminari in the project, I'm not sure if such mixing would be a good idea.
FancyGrid looks tempting, but it seems to be not maintained and so I'm not sure, if it's good idea to use it.
Do you know anything more?
There's a railscasts that may be relevant. See here
Fancygrid is currently in the proess of being refactored. Please be patient, there will definitely be a new release.
A new version of FancyGrid has been just released.
You can find all related plugins here:
https://www.ruby-toolbox.com/categories/Table_Builders
So there are several other plugins:
Tabletastic
TableForCollection
Tableasy

Can't use "acts_as_url" in ruby on rails 3

I'm newb and I'm sorry because of my dumb question! Please, help me!!
I'm working with Rails 3, and this my problem:
I have a model name: Photo using gem 'mongoid'.
I want to make a permalinks which are readable url instead of unreadable '_id' generated from mongoid!
After searching in google, I found a gem called 'stringex'! I decided to use this gem, and put this line in my Gemfile:
gem 'stringex'
then ran "bundle install' to use it.
I just do everything following the guide in github Readme_rsl/stringex but the trouble occurs:
undefined method `acts_as_url' for Photo:Class
Is it because ROR 3 doesn't support this gem? Or I missed something?
Please, I need help!
This is probably not the answer you're looking for, but I think the answer is "you can't do that." At least not currently.
The gem you mention is intimately tied to ActiveRecord (see this issue ticket). If you look in the stringex source code in lib/stringex.rb, you can see that acts_as_url is only included on ActiveRecord and not on Mongoid.
What's happening is that you're using Mongoid on your model, and the nice acts_as_url methods are not attached to the Mongoid::Document. It MAY be as simple as just modifying lib/stringex.rb to also include acts_as_url on Mongoid, though I assume that if it were that simple it would already have been done.
So where does that leave you? There are other ways to generate slugs. I haven't used any of them, so I can't speak to which ones are good or not. Googling "mongoid slug generation" can hopefully point you in the right direction.
Your model needs to have a url attribute to store the nice url in the database for later use.
I don't know why the don't mention that on the README. I found that out after reading a couple of articles.
In my case restarting the rails server command helped.
This isn't difficult to write yourself. And it will help you to understand a few parts of rails and routes.
Add a 'permalink' column to the db.
Do a find_by_permalink(params[:id]) in the controller
Add a def to_param method to the model and return the permalink
column
Add a create_permalink before_validations method. Generate the
permalink however you like and store it in the db.
The only trick is ensuring uniqueness and handling name (and url) changes. stringex looks like it helps with uniqueness, not with name changes.
There are other gems to help with name changes (aliasing and redirecting if there's a new name) if you care about that. You can handle that in different ways.

Rails gem/plugin that gives suggestions how to optimize your DB queries

Some time ago I saw in a screencast showing a gem or plugin, which was able to suggest how to optimize your Rails DB queries, like where to use include or add an index and so on... Now I can't remember which screencast that was, but maybe somebody knows what I am talking about, I mean that gem/plugin.
Actually I have found it was on this screencast, and it is called bullet
You're probably thinking about https://github.com/eladmeidar/rails_indexes , possibly https://github.com/samdanavia/ambitious_query_indexer .
Good luck.
Was it rails_best_practices?
Now You can use my newly created gem 'query_optimizer'
You can optimize queries as Post.optimize_query(:comments)

Standard Rails Gem for storing what User created/updated/deleted any Record?

What's the standard/best option out there for this kind of version control? The main thing I'm looking for is to track what user edited a record.
I've seen these so far and am wondering what your take is:
PaperTrail
ActsAsAudited
VestalVersions
The plugins you mentioned all seem to take the same approach, and seem to be somewhat similar in approach: use a seperate table to store the old versions.
None of them seem to be really rails3-ready (looking at the generators), but PaperTrail reportedly should work with rails3, and has the most recent commit.
You could also look at the ruby-toolbox user-stamping and versioning. There you can see which project has the most "traction", which has the most recent commits. Which sometimes can help to make a choice between similar options.
For stamping user_ids onto rows there is the the userstamp plugin
http://github.com/delynn/userstamp
EDIT:
Based on the requirement mentioned in your comment, I would recommend act_as_audited
http://github.com/collectiveidea/acts_as_audited
We are using it successfully for a very large application.
Peer
I think PaperTrail is what you need to solve this problem.
With PaperTrail you can track and see all changes ,to any model, with user id of who made the changes.
It is currently the best maintained project of the three you linked
HI #viatropos I thought that these two links might prove to be helpful
http://api.rubyonrails.org/classes/ActiveRecord/Observer.html
http://www.robbyonrails.com/articles/2007/04/27/observers-big-and-small

Resources