ruby on rails - vestal_versions and htmldiff question of reversion -


i'm guessing there's easier way i'm doing code less unwieldy.

i had trouble understanding how use revert_to method... wanted call 2 different versions @ same time, doesn't seem way vestal_versions works.

this code works, i'm wondering if i'm making harder needs , i'd find out before 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 in conjunction htmldiff version changes.

<div id="content">   <% if params[:versions] %>     <%= article.diff(@content1, @content2) %>   <% else %>     <%= @article.content %>   <% end %> </div> 

i think looking changes_between method vestal_versions provides.

@article = article.find(params[:id])  if params[:versions]   v = params[:versions].split(',')   @article_changes = @article.changes_between(v.first.to_i, v.last.to_i) end 

then @article_changes hash of changes between versions. like

{"content" => ["first version content", "second version content"]} 

maybe different depending on have versioned.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -