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| %>
<tr class="odd">
<td><input type="checkbox" /></td>
<td><%= %></td>
<td><%= version.created_at%></td>
<td><%= undo_link %></td>
<td><%=
version.update_attributes :summary => 'version' %></td>
</tr>


</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 :)


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 13, '12 at 10:13a
activeFeb 13, '12 at 10:13a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Sj: 1 post

People

Translate

site design / logo © 2023 Grokbase