I have a strange problem. My audited gem does not work in my views when i have this code in my contracten view:
<p><%= @contracten.respond_to?(:audits) %></p>
<br />
<%= @contracten.audits.each do |audit| %>
<%= audit.version %>
<br />
<% end %>
it gives the following error: undefined method
audits' for nil:NilClass`
When i only have this line in my views: <p><%= @contracten.respond_to?(:audits) %></p>
It showes false instead of true so i don't think my controller is working properly.
My controller show:
def show
add_breadcrumb 'Contract Bekijken', :contracten_path
@contracten = Contracten.find(params[:id])
end
My model:
class Contracten < ActiveRecord::Base
audited
has_attached_file :pdf
attr_accessible :betalingsperiodeeenheidid, :betalingstermijn, :contractduur, :contractid, :contractsoortid, :datumeinde, :datumingang, :naam, :omschrijving, :opzegtermijn, :organisatieid, :persoonid, :vestigingid, :pdf
end
I posted a similar question here: Show Last modified tables/records Rails 3.2 but that's not specific about audited. i did not find a simplier gem for it so this may work. but i'm still struggling with the views
<%= @contracten.respond_to?(:audits) %>
in my views and then with the debug code it gives this output: --- ... false – Kees Sonnema Jul 19 '12 at 08:29