diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 8b3cf55a..a7666584 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -24,18 +24,18 @@ module PaperTrail # trail). See `PaperTrail::Controller.info_for_paper_trail` for how to store data from # the controller. # :versions the name to use for the versions association. Default is `:versions`. - # :version_name the name to use for the method which returns the version the instance was reified from. + # :version the name to use for the method which returns the version the instance was reified from. # Default is `:version`. def has_paper_trail(options = {}) # Lazily include the instance methods so we don't clutter up # any more ActiveRecord models than we have to. send :include, InstanceMethods - class_attribute :version_name - self.version_name = options[:version_name] || 'version' + class_attribute :version_association_name + self.version_association_name = options[:version] || :version # The version this instance was reified from. - attr_accessor self.version_name + attr_accessor self.version_association_name class_attribute :version_class_name self.version_class_name = options[:class_name] || 'Version' @@ -131,7 +131,7 @@ module PaperTrail end def source_version - send self.class.version_name + send self.class.version_association_name end def record_create diff --git a/lib/paper_trail/version.rb b/lib/paper_trail/version.rb index ecd59cda..b5038c3a 100644 --- a/lib/paper_trail/version.rb +++ b/lib/paper_trail/version.rb @@ -69,7 +69,7 @@ class Version < ActiveRecord::Base end end - model.send "#{model.class.version_name}=", self + model.send "#{model.class.version_association_name}=", self unless options[:has_one] == false reify_has_ones model, options[:has_one] diff --git a/test/dummy/app/models/legacy_widget.rb b/test/dummy/app/models/legacy_widget.rb index 7d63613f..11ba988c 100644 --- a/test/dummy/app/models/legacy_widget.rb +++ b/test/dummy/app/models/legacy_widget.rb @@ -1,4 +1,4 @@ class LegacyWidget < ActiveRecord::Base - has_paper_trail :ignore => :version, - :version_name => 'custom_version' + has_paper_trail :ignore => :version, + :version => 'custom_version' end