What's the best way to store the ActiveRecord Models with Versions and their Associations with Versions? - ruby-on-rails

If all I have is one model (for example Wiki) and want to save it along with its versions, I could use acts_as_versioned plugin which stores the wikis in "wikis" table and its versions in "wikis_versions" table. This is plain an simple even if I want to moderate the latest version before showing it to the public using a field as status with "pending review/ published".
What's the best way to handle Wiki with associations (for example attachments, assets,..) which also have versions? And how would you moderate it? Do you create a new version to wiki even though only its association is changed just to keep the flow going, if so what about other associations?
What's the best way to handle it with little db overhead?
Thanks in advance.

I have used both acts_as_versioned and acts_as_audited.
I prefer the latter because it uses a single table. Using acts_as_versioned we've had issues with changes to versioned tables requiring extra migrations => this adds extra complexity to our build and deployment process.

Richard Livsey has a nice plugin for this that works with acts_as_versioned.
http://github.com/rlivsey/acts_as_versioned_association/tree/master

Related

How to handle article revisions?

I'm creating a knowledge base web app in Ruby on Rails. I'm looking for various ideas on how to handle revisions of the same article.
At this point, I have a table called contents and versions. Versions belongs_to the Content table and has a foreign_key to content_ID. However, from this point on, I'm not sure how I'm going to implement saving to different versions, auto-save, and allow authors to recover from certain version and making a particular version as the current version. Any suggestions, opinions, and links are all appreciated.
Version control can be tricky but check out paper_trail: https://github.com/airblade/paper_trail

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

Versioned associations using vestal_versions?

I'd like to be sure if vestal_versions does support versioned associations (it seems like it doesn't) before switching out to another versioning gem that can support versioned associations e.g => has_versioning. I haven't looked at the code yet but I couldn't find anything related with versioned associations from the readme file or the issue section on github. Help would be appreciated!
(At the moment of writing this) There is an associations branch in the official vestal_versions repository, It is still a basic idea and isn't merged yet in the master branch. So I decided to go with another versioning gem, specifically acts_as_revisable following the instructions in this blog post.
I'm looking for something that appears to be very close to your needs. But I don't need to revert the associated objects, just to record them. I was thinking of handle it in a nosql way. So I can save the model version and the associations would be embedded documents.
So I can compare versions in a more comprehensive way. Right now I use paper_trail, but as it can't handle associations, it's not possible to store the tags associated to a model and see how it changes through time.

rails project help

i am trying to get my head around the best way to develop an app in ruby on rails
i have a ducument creation system that for each document has multiple associations ie text docs, images, optional accessories etc. I have created this system now to do CRUD.
The next thing i want to do is have each document able to be translated into multiple languages and each document need to be versionized and audited with whats changed when and who dun it etc. Also i need to be able to clone a document for another user so he can then edit it for himself and with all above version and audit features.
I have looked at Globalize2, acts_as_audited, acts_as_versioned, paper_trail and deep_clone and sort of need abit of each !
Please can anyone help me with how or what is the best method of develping this app ? Is there better more suited plugins to use ? can these be used with each other ? and what would be the best process to set this up ?
any help would be most appreciated.
thanks
Rick
thanks askegg for your reply
the thing is acts_as_version does not include your models relations and i need to version each document model along with the children asscociated models ?
So basically if i dont use Globalize my transplated documents will just be other versions but in a different language. Is that correct ? I thought that is what Globalize does ?
thanks alot
rick
It seems you have a grasp of the basic structure you want and have investigated some alternatives.
First pass of my reading: You have a Document model, probably with a polymorphic association to an Asset model. Come to think of it, a Document is just a type of Asset, so one could inherit from the other - perhaps Single Table Inheritance.
From here, add acts_as_versioned to deal with ....well, versioning. This should also be able to give you the differences between various versions, just ensure you record the user_id along with the change.
I am not sure Globalise or i18n will help you here, as they are more geared to translating the web site itself with reasonably static content, not highly dynamic documents such as you're dealing with. I would leave translations to the users and use i18n to present different translations of the web site itself.
Cloning a document should not be too difficult - just create a new Document and populate the information in it. You will probably need a cloned_from_id field and build a self referential has_many in the model.
Well, they are the thoughts off the top of my head.
I was thinking you might treat each image, document, pdf, whatever as separate assets each with their own versions - operating independently of any other. If you need to clone a document and it's children, then you would need to iterate over the children and clone them as well - and their children's children. etc.
Globalise (or any other translation platform) is only really good for set/simple statements. Due to syntax and grammatical issues I would not expect it to be able achieve good translations between languages. Humans are great at that.
It occurs to me that you might want to think about using Git as a document store. This gives you full document versioning with tracking changes. See this presentation for some ideas. Don't worry about all the tech details - just think what it can do for you. The good stuff start about 15 minutes in. The Grit Ruby library can be found here.

Is there a good admin generator for Ruby on Rails?

My current project is in Rails. Coming from a Symfony (PHP) and Django (Python) background, they both have excellent admin generators. Seems like this is missing in Rails.
For those who aren't familiar with Symfony or Django, they both allow you to specify some metadata around your models to automatically (dynamically) generate an admin interface to do the common CRUD operations. You can create an entire Intranet with only a few commands or lines of code. They have a good appearance and are extensible enough for 99% of your admin needs.
I've looked for something similar for Rails, but all of the projects either have no activity or they died long ago. Is there anything to generate an intranet/admin site for a rails app other than scaffolding?
Active Admin (http://activeadmin.info/) was released in May of 2011, and looks like it's going to become the best Rails 3 option.
rails_admin appears to be the latest-n-greatest free project as of January 2011.
...best of all, there has been a lot of activity in the repository.
Scaffolding is the normal way to create an admin backend BUT there is a project called ActiveScaffold which may solve your problem.
Here is a roundup of a few options, including more than just ActiveScaffold.
ActiveScaffold is available for Rails 2.3.x :)
Just for someonse's info who have found this question one year later like me :)
ActiveScaffold is a good solution, but if you want a more configurable and powerful tool, I think Typus is a great solution:
http://github.com/fesplugas/typus
You have mainly two:
ActiveScaffolding: the most popular but be careful with rails 2.1
Streamlined
ActiveScaffold is by far and away the most configurable/easiest to integrate/most automagic scaffolding around at the moment.
It has built in ajax support, near seamless db introspection and it even plays nicely with legacy Oracle databases (which can be a real pain in Rails).
Try it: http://activescaffold.com/
Have a look at Casein (http://www.caseincms.com/), might be what you're looking for.
Having also tried typus, caseincms and ActiveScaffold over the weekend, I can't rave enough about admin_data.
It is
super-quick to install (Rails 3 is the gem, Rails 2.3 is a plugin branch,
no digging through trees on github),
unintrusive (all code is in the vendor/admin_data folder or the gem where it belongs),
requires no set-up and optional configuration is one block in one file in your app,
correctly (!) gets all model information from your model definitions (primary_key, foreign_key, relationships etc.),
including multiple databases, SQL Server connections via activerecord-sqlserver-adapter, and even composite primary keys, as everything is abstracted on top of ActiveRecord, if you model works, admin_data will work,
works great with legacy data for the above reasons,
uses your existing authentication solution which is called in the most wonderful DRYness in your configuration file.
It maybe less flexible or pretty than other solutions, but this plugin does many thingks right for quick admin panel setup.
The most common way to create a CRUD interface is to use Scaffold.
./script/generate scaffold_resource MyModel property:type property2:type2
This command would generate a CRUD interface for the model named MyModel (singular) with two properties. Properties is what's called columns in DB lingo. So you could have name:string age:integer active:boolean etc.
I can suggest you active_admin that is best
Active Admin main site

Resources