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 ?

pages_helper

module PagesHelper

def undo_link

   link_to("undo",

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

pages_controller

  def revert
    @version = Version.find(params[:id])
    if @version.reify
      @version.reify.save!
    else
      @version.item.destroy
    end

    link_name = params[:redo] == "true" ? "undo" : "redo"
  link = view_context.link_to(link_name,

revert_version_path(@version.next, :redo => !params[:redo]), :method
=> :post)
redirect_to :back, :notice => “Undid #{@version.event}. #{link}”
end

pages show.html.erb

<tbody>
                            <% @page.versions.reverse.each do |

version| %>



<%= %>
<%= version.created_at%>
<%= undo_link %>
<%=
version.update_attributes :summary => ‘version’ %>
                      </div>
                  <% end %>

routes

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

“revert_version”

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:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs