I'm trying to make a version listing with Paper trail, that user will be able to see a difference between versions and get back to the older version.
I've found out how to make a listing and links to this versions, but for some reasons, I'm getting an error, when I try to reify the last two versions. It says: undefined method `reify' for nil:NilClass
Does anyone knows, what to do about it and what about the diff versioning?
# controller
def edit
@page = Page.find(params[:id])
@versions = @page.versions
@page = @page.versions[params[:version].to_i].reify if params[:version]
end
# Model
class Page < ActiveRecord::Base
validates :title, :presence => true
belongs_to :category
has_paper_trail
end
# View
<% @versions.each do |version| %>
<ul>
<li><%= version.id %> <%= link_to "Previous version", {:version => (version) }%></li>
</ul>
<% end %>
<%= link_to "Go to current version"%>
Thank you for your help