I have a table, folders that I want some other tables to reference, so far my migration script looks like this:
create_table :folders do |t|
t.timestamps
end
....
change_table table1 do |t|
t.references :folders
end
change_table table2 do |t|
t.references :folders
end
change_table table3 do |t|
t.references :folders
end
change_table table4 do |t|
t.references :folders
end
Since I’m doing essentially the same thing to each table, is there a more concise and maintainable way to write this?
Thanks
Try to do this:
I hope you don’t name tables with pattern
table{#n}and give them good names in your actual code 🙂