forked from collectiveidea/audited
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed 'association' to 'associated' as Rails 3.1 introduces conflicting 'association' method.
- Loading branch information
Eugene Diachkin
committed
Jun 5, 2011
1 parent
aab76bc
commit ba013fb
Showing
9 changed files
with
72 additions
and
14 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
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
23 changes: 23 additions & 0 deletions
23
lib/generators/acts_as_audited/templates/rename_association_to_associated.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,23 @@ | ||
class <%= migration_class_name %> < ActiveRecord::Migration | ||
def self.up | ||
if index_exists? :audits, [:association_id, :association_type], :name => 'association_index' | ||
remove_index :audits, :name => 'association_index' | ||
end | ||
|
||
rename_column :audits, :association_id, :associated_id | ||
rename_column :audits, :association_type, :associated_type | ||
|
||
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index' | ||
end | ||
|
||
def self.down | ||
if index_exists? :audits, [:associated_id, :associated_type], :name => 'associated_index' | ||
remove_index :audits, :name => 'associated_index' | ||
end | ||
|
||
rename_column :audits, :associated_type, :association_type | ||
rename_column :audits, :associated_id, :association_id | ||
|
||
add_index :audits, [:association_id, :association_type], :name => 'association_index' | ||
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
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,18 @@ | ||
ActiveRecord::Schema.define do | ||
create_table :audits, :force => true do |t| | ||
t.column :auditable_id, :integer | ||
t.column :auditable_type, :string | ||
t.column :user_id, :integer | ||
t.column :user_type, :string | ||
t.column :username, :string | ||
t.column :action, :string | ||
t.column :audited_changes, :text | ||
t.column :version, :integer, :default => 0 | ||
t.column :comment, :string | ||
t.column :created_at, :datetime | ||
t.column :remote_address, :string | ||
t.column :association_id, :integer | ||
t.column :association_type, :string | ||
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