Forum: Ruby on Rails Model for Tracking changes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Edbd4fa3c85c5f1f2b1d2963baed830d?d=identicon&s=25 Chinmay Kulkarni (Guest)
on 2006-03-06 16:04
(Received via mailing list)
Hi!

I'm new to Rails (and ruby in general). I was planning to implement a
whiteboard like system, in which changes made by users to the board are
automatically tracked.
Currently, I've implemented it as a model Post which :has_many Boards. A
new Board is added to the Post every time a change is submitted (with a
created_at timestamp). This allows saving multiple versions of the
board, but has the drawback that:
a) The board is replicated even if there is only a marginal change.
b) There is no easy way (I know) to diff two versions.

Would be very grateful it anyone could help me out with some better
model or point me in the right direction.

Yours,
Chinmay
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2006-03-06 16:29
(Received via mailing list)
On 3/6/06, Chinmay Kulkarni <f2005388@bits-pilani.ac.in> wrote:
> b) There is no easy way (I know) to diff two versions.
>
> Would be very grateful it anyone could help me out with some better
> model or point me in the right direction.
>
> Yours,
> Chinmay

You can try installing my acts_as_versioned plugin:
http://ar-versioned.rubyforge.org (Use the plugin version instead of
the gem).

The Rails Recipe book has a great intro recipe on how to use it too.

It still saves revisions for small changes, but you can specify which
fields to check with:

  class Post < AR::Base
    acts_as_versioned :if_changed => [:title, :body]
  end

You can also save without a revision:

  @post.save_without_revision

Diffing isn't included, but you can look at the i2 source to see how
the Rails Wiki handles it:

http://dev.rubyonrails.org/svn/tools/i2/trunk

--
Rick Olson
http://techno-weenie.net
This topic is locked and can not be replied to.