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
Related
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
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.
Does anyone know if there is a Rails gem/plugin/tutorial that shows how to create a Badge/Achievement system similar to what stackoverflow uses.
Thanks.
You might also want to try the achievements gem: https://github.com/mrb/achievements
It's based on Redis, so you'll need to get that working first. Basically, you define a bunch of achievement contexts (pages viewed, messages sent, etc.) along with multiple levels if necessary. Then, you increment your value appropriately upon certain events, and you can then check if the achievement has been reached.
This link also has a relatively detailed explanation of the thinking behind a badge/achievement system: RoR Achievement System - Polymorphic Association & Design Issues
check out https://github.com/paulca/paths_of_glory
I think it's less a framework but a design question. If you know how to build it in an object-oriented way, you'll eventually know how to build it in Rails too.
If you're a Rails newbie, check out the Rails Guide on "Active Record Associations" and try to identify the models and the associations of your "badge/achievment system".
Besides that: No, I don't know of any turnkey-gem/plugin/tutorial that would help you build such a system.
There is also Gioco, which I haven't yet tried:
http://joaomdmoura.github.io/gioco/
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.
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