4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/acts_as_data_owner/migration.rb', line 4
def acts_as_data_owner_for(table_name, *args)
options = args.
fields = [:creator, :owner, :updater]
fields += [options[:include]].flatten if options[:include]
fields -= [options[:exclude]].flatten if options[:exclude]
prefix = options[:prefix] if options[:prefix]
change_table table_name do |t|
fields.each do |f|
t.references(f)
end
end
fields.each do |f|
add_index table_name, "#{f}_id",:name=>(prefix ? "#{prefix}_#{f}" : "index_#{table_name}_on_#{f}" )
end
end
|