vestal_versions and htmldiff question of reversion...
Posted
by holden
on Stack Overflow
See other posts from Stack Overflow
or by holden
Published on 2010-04-28T19:51:25Z
Indexed on
2010/04/28
19:57 UTC
Read the original article
Hit count: 311
I'm guessing there's probably an easier way to do what I'm doing so that the code is less unwieldy.
I had trouble understanding how to use the revert_to method... i wanted something where i could call up two different versions at the same time, but this doesn't seem to be the way that vestal_versions works.
This code works, but I'm wondering if I'm making something harder than it needs to be and I'd like to find out before I delve deeper.
@article = Article.find(params[:id])
if params[:versions]
v = params[:versions].split(',')
@article.revert_to(v.first.to_i)
@content1 = @article.content
@article.revert_to(v.last.to_i)
@content2 = @article.content
end
In case you're wondering, I'm using this in conjunction with HTMLDIFF to get the version changes.
<div id="content">
<% if params[:versions] %>
<%= Article.diff(@content1, @content2) %>
<% else %>
<%= @article.content %>
<% end %>
</div>
© Stack Overflow or respective owner