Log Versioning

I am trying to make a list of versions using Paper trail, this user will be able to see the difference between the versions and return to the old version.

I learned how to list and link to this version, but for some reason I get an error when I try to confirm the last two versions. It says: undefined `reify 'method for nil: NilClass

Does anyone know what to do with this, and what to do with the diff version?

# 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"%>

thanks for the help

+1
source share
1 answer

, , @page.versions[params[:version].to_i] , @page.versions - , .

:

Version.find(params[:version])

@page.versions.find(params[:version])
+1

Source: https://habr.com/ru/post/1527592/


All Articles