Implementing a history feature for a basic wiki app maybe papertrails ?

I have been trying a lot for the last two days to implement a history
feature for my basic wiki rails app. I am using papertrails for that.
But according to my below code, whenever i click undo. it reverts back
to the first edit instead of the last edit. does that means its not
storing the last edit ? Any help please ?


    module PagesHelper

    def undo_link

revert_version_path(@page.versions.last.reify ), :method => :post)


      def revert
        @version = Version.find(params[:id])
        if @version.reify

        link_name = params[:redo] == "true" ? "undo" : "redo"
      link = view_context.link_to(link_name,
revert_version_path(, :redo => !params[:redo]), :method
=> :post)
      redirect_to :back, :notice => "Undid #{@version.event}. #{link}"

pages show.html.erb

                                <% @page.versions.reverse.each do |
version> %>
                                <tr class="odd">
                                  <td><input type="checkbox" /></td>
                                  <td><%= %></td>
                                  <td><%= version.created_at%></td>
                                  <td><%= undo_link %></td>
version.update_attributes :summary => 'version' %></td>

                      <% end %>


    match "wikis/:wiki_id/pages/:id/revert" => 'pages#revert', :as =>

Also, the route generated with this breaks when a new page is created
under a wiki.

if there is some other tool. then i would like to know that which
would make this task easy :slight_smile: