Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Conflict with other gems that use the tag method #71

Open
wants to merge 4 commits into from

1 participant

@bishopandco

this might not be ideal... but seams to be a popular issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 6, 2010
  1. renamed to avoid conflict with tags

    Michael Bishop authored
Commits on Aug 7, 2010
  1. renamed to avoid conflicts

    Michael Bishop authored
Commits on Jul 9, 2011
  1. Tries to remove tag conflict with actst_as_taggable_on by using versi…

    Michael Bishop authored
    …onable_tag instead of tag
  2. commited some files that shouldn't be there

    Michael Bishop authored
This page is out of date. Refresh to see the latest.
View
6 README.rdoc
@@ -81,13 +81,13 @@ For the most part, version 1.0 of <tt>vestal_versions</tt> is backwards compatib
change_table :versions do |t|
t.belongs_to :user, :polymorphic => true
t.string :user_name
- t.string :tag
+ t.string :versionable_tag
end
change_table :versions do |t|
t.index [:user_id, :user_type]
t.index :user_name
- t.index :tag
+ t.index :versionable_tag
end
* When a model is created (or updated the first time after being versioned), an initial version record with a number of 1 is no longer created. These aren't used during reversion and so they end up just being dead weight. Feel free to scrap all your versions where <tt>number == 1</tt> after the upgrade if you'd like to free up some room in your database (but you don't have to).
@@ -120,7 +120,7 @@ There are a handful of exciting new additions in version 1.0 of <tt>vestal_versi
@user.name # => "Steve Richert"
@user.update_attribute(:last_name, "Jobs")
@user.name # => "Steve Jobs"
- @user.tag_version("apple")
+ @user.versionable_tag_version("apple")
@user.update_attribute(:last_name, "Richert")
@user.name # => "Steve Richert"
@user.revert_to("apple")
View
4 lib/generators/vestal_versions/migration/templates/migration.rb
@@ -7,7 +7,7 @@ def self.up
t.text :modifications
t.integer :number
t.integer :reverted_from
- t.string :tag
+ t.string :versionable_tag
t.timestamps
end
@@ -17,7 +17,7 @@ def self.up
t.index [:user_id, :user_type]
t.index :user_name
t.index :number
- t.index :tag
+ t.index :versionable_tag
t.index :created_at
end
end
View
2  lib/vestal_versions/changes.rb
@@ -15,7 +15,7 @@ module InstanceMethods
# Collects an array of changes from a record's versions between the given range and compiles
# them into one summary hash of changes. The +from+ and +to+ arguments can each be either a
# version number, a symbol representing an association proxy method, a string representing a
- # version tag or a version object itself.
+ # version versionable_tag or a version object itself.
def changes_between(from, to)
from_number, to_number = versions.number_at(from), versions.number_at(to)
return {} if from_number == to_number
View
2  lib/vestal_versions/deletion.rb
@@ -31,7 +31,7 @@ def delete_version?
end
def create_destroyed_version
- create_version({:modifications => attributes, :number => last_version + 1, :tag => 'deleted'})
+ create_version({:modifications => attributes, :number => last_version + 1, :versionable_tag => 'deleted'})
end
end
View
4 lib/vestal_versions/version.rb
@@ -55,7 +55,7 @@ def restore!
end
def restore
- if tag == 'deleted'
+ if versionable_tag == 'deleted'
attrs = modifications
class_name = attrs['type'].blank? ? versioned_type : attrs['type']
@@ -72,7 +72,7 @@ def restore
model
else
- latest_version = self.class.find(:first, :conditions => {:versioned_id => versioned_id, :versioned_type => versioned_type, :tag => 'deleted'})
+ latest_version = self.class.find(:first, :conditions => {:versioned_id => versioned_id, :versioned_type => versioned_type, :versionable_tag => 'deleted'})
latest_version.nil? ? nil : latest_version.restore
end
end
View
14 lib/vestal_versions/version_tagging.rb
@@ -16,7 +16,7 @@ module InstanceMethods
# be built to house the given tag if the parent object's current version number is 1.
def tag_version(tag)
v = versions.at(version) || versions.build(:number => 1)
- v.tag!(tag)
+ v.versionable_tag!(tag)
end
end
@@ -25,23 +25,23 @@ module VersionMethods
extend ActiveSupport::Concern
included do
- validates_uniqueness_of :tag, :scope => [:versioned_id, :versioned_type], :if => :validate_tags?
+ validates_uniqueness_of :versionable_tag, :scope => [:versioned_id, :versioned_type], :if => :validate_tags?
end
# Attaches the given string to the version tag column. If the uniqueness validation fails,
# nil is returned. Otherwise, the given string is returned.
- def tag!(tag)
- write_attribute(:tag, tag)
- save ? tag : nil
+ def versionable_tag!(versionable_tag)
+ write_attribute(:versionable_tag, versionable_tag)
+ save ? versionable_tag : nil
end
# Simply returns a boolean signifying whether the version instance has a tag value attached.
def tagged?
- !tag.nil?
+ !versionable_tag.nil?
end
def validate_tags?
- tagged? && tag != 'deleted'
+ tagged? && versionable_tag != 'deleted'
end
end
View
6 lib/vestal_versions/versions.rb
@@ -39,8 +39,8 @@ def after(value)
# * A Numeric object: Typically a positive integer, these values correspond to version numbers
# and the associated version record is found by a version number equal to the given value
# rounded down to the nearest integer.
- # * A String: A string value represents a version tag and the associated version is searched
- # for by a matching tag value. *Note:* Be careful with string representations of numbers.
+ # * A String: A string value represents a version versionable_tag and the associated version is searched
+ # for by a matching versionable_tag value. *Note:* Be careful with string representations of numbers.
# * A Symbol: Symbols represent association class methods on the +has_many+ versions
# association. While all of the built-in association methods require arguments, additional
# extension modules can be defined using the <tt>:extend</tt> option on the +versioned+
@@ -51,7 +51,7 @@ def at(value)
case value
when Date, Time then last(:conditions => ["#{aliased_table_name}.created_at <= ?", value.to_time])
when Numeric then find_by_number(value.floor)
- when String then find_by_tag(value)
+ when String then find_by_versionable_tag(value)
when Symbol then respond_to?(value) ? send(value) : nil
when Version then value
end
View
2  spec/support/schema.rb
@@ -18,7 +18,7 @@ def self.up
t.text :modifications
t.integer :number
t.integer :reverted_from
- t.string :tag
+ t.string :versionable_tag
t.timestamps
end
end
View
2  spec/vestal_versions/deletion_spec.rb
@@ -22,7 +22,7 @@
it "creates a version with a tag 'deleted'" do
subject.destroy
- VestalVersions::Version.last.tag.should == 'deleted'
+ VestalVersions::Version.last.versionable_tag.should == 'deleted'
end
end
View
4 spec/vestal_versions/version_tagging_spec.rb
@@ -12,9 +12,9 @@
tag_name = 'TAG'
last_version = user.versions.last
- last_version.tag.should_not == tag_name
+ last_version.versionable_tag.should_not == tag_name
user.tag_version(tag_name)
- last_version.reload.tag.should == tag_name
+ last_version.reload.versionable_tag.should == tag_name
end
it 'creates a version record for an initial version' do
Something went wrong with that request. Please try again.