Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues #4 and #9 #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions acts_as_versioned.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Gem::Specification.new do |s|
## Leave these as is they will be modified for you by the rake gemspec task.
## If your rubyforge_project name is different, then edit it and comment out
## the sub! line in the Rakefile
s.name = 'acts_as_versioned'
s.version = '0.6.0'
s.date = '2012-03-28'
s.name = 'cure_acts_as_versioned'
s.version = '0.6.3'
s.date = '2014-03-26'
s.rubyforge_project = 'acts_as_versioned'

## Make sure your summary is short. The description may be as long
Expand All @@ -25,9 +25,15 @@ Gem::Specification.new do |s|
## List the primary authors. If there are a bunch of authors, it's probably
## better to set the email to an email list or something. If you don't have
## a custom homepage, consider using your GitHub URL or the like.
s.authors = ["Rick Olson"]
s.email = '[email protected]'
s.homepage = 'http://github.com/technoweenie/acts_as_versioned'
# The real primary author is obviously still Rick Olson, but it seems important
# to point to the correct github repo and since Rick is not in charge of that
# particular repo... Ward, 2011-06-19
#s.authors = ["Rick Olson"]
#s.email = '[email protected]'
#s.homepage = 'http://github.com/technoweenie/acts_as_versioned'
s.authors = ["Ward Vandewege"]
s.email = '[email protected]'
s.homepage = 'http://github.com/cure/acts_as_versioned'

## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
Expand Down Expand Up @@ -82,4 +88,4 @@ Gem::Specification.new do |s|
## Test files will be grabbed from the file list. Make sure the path glob
## matches what you actually use.
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
end
end
12 changes: 9 additions & 3 deletions lib/acts_as_versioned.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def acts_as_versioned(options = {}, &extension)
self.version_association_options = {
:class_name => "#{self.to_s}::#{versioned_class_name}",
:foreign_key => versioned_foreign_key,
:dependent => :delete_all
}.merge(options[:association_options] || {})

if block_given?
Expand Down Expand Up @@ -427,8 +426,13 @@ def create_versioned_table(create_table_options = {})
end

self.versioned_columns.each do |col|
limit = col.limit
if col.limit == 10 and col.type == :integer
# Avoid 'No integer type has byte size 10' under MySQL
limit = 8
end
self.connection.add_column versioned_table_name, col.name, col.type,
:limit => col.limit,
:limit => limit,
:default => col.default,
:scale => col.scale,
:precision => col.precision
Expand All @@ -442,7 +446,9 @@ def create_versioned_table(create_table_options = {})
:precision => type_col.precision
end

self.connection.add_index versioned_table_name, versioned_foreign_key
# Make sure not to create an index that is too long (rails limits index names to 64 characters from version 3.0.3)
name = 'index_' + versioned_table_name + '_on_' + versioned_foreign_key
self.connection.add_index versioned_table_name, versioned_foreign_key, :name => name[0,63]
end

# Rake migration task to drop the versioned table
Expand Down