-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #439 from bli/merge-with-lyfeyaj
supporting has_many reification based on @lyfeyaj and @NullVoxPopuli 's works
- Loading branch information
Showing
23 changed files
with
1,038 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ Gemfile.lock | |
vendor/* | ||
.idea | ||
.rvmrc | ||
.tags | ||
.tags_sorted_by_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/generators/paper_trail/templates/add_transaction_id_column_to_versions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AddTransactionIdColumnToVersions < ActiveRecord::Migration | ||
def self.up | ||
add_column :versions, :transaction_id, :integer | ||
add_index :versions, [:transaction_id] | ||
end | ||
|
||
def self.down | ||
remove_index :versions, [:transaction_id] | ||
remove_column :versions, :transaction_id | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
lib/generators/paper_trail/templates/create_version_associations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateVersionAssociations < ActiveRecord::Migration | ||
def self.up | ||
create_table :version_associations do |t| | ||
t.integer :version_id | ||
t.string :foreign_key_name, :null => false | ||
t.integer :foreign_key_id | ||
end | ||
add_index :version_associations, [:version_id] | ||
add_index :version_associations, [:foreign_key_name, :foreign_key_id], :name => 'index_version_associations_on_foreign_key' | ||
end | ||
|
||
def self.down | ||
remove_index :version_associations, [:version_id] | ||
remove_index :version_associations, :name => 'index_version_associations_on_foreign_key' | ||
drop_table :version_associations | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'paper_trail/version_association_concern' | ||
|
||
module PaperTrail | ||
class VersionAssociation < ::ActiveRecord::Base | ||
include PaperTrail::VersionAssociationConcern | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'active_support/concern' | ||
|
||
module PaperTrail | ||
module VersionAssociationConcern | ||
extend ::ActiveSupport::Concern | ||
|
||
included do | ||
belongs_to :version | ||
|
||
attr_accessible :version_id, :foreign_key_name, :foreign_key_id if PaperTrail.active_record_protected_attributes? | ||
end | ||
end | ||
end |
Oops, something went wrong.