add_index :section_edits, ['admin_user_id', 'section_id' ]
add_index :sections, [:name, :page_id]
I know the variables are different, but my question is regarding how to pass the variables (i.e. :page_id vs 'page_id'). Does it makes a difference? Which one is better?
I have noted that when I use :name it is already defined before I pass the variable, but if I use 'section_id' , following a tutorial, this variable was not previously defined.
Here is some sample code:
class CreateSections < ActiveRecord::Migration
def change
create_table :sections do |t|
t.references :page
t.string :name
t.string :content_type
t.integer :position
t.boolean :visible
t.text :content
t.timestamps
end
add_index :sections, [:name, :page_id]
end
end
class CreateSectionEdits < ActiveRecord::Migration
def change
create_table :section_edits do |t|
t.references :admin_user
t.references :section
t.timestamps
end
add_index :section_edits, ['admin_user_id', 'section_id' ]
end
end
Thank you!