I am new to Rails. I am wondering if I need add_index for both migrations?
I am trying to identify users and events. Each user can have many events, and each event can have many users. so I would do something like this:
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation
has_many :events
.
.
.
and then this:
class Event < ActiveRecord::Base
attr_accessible :name
has_many :users
.
.
.
I need to add add_index for both:
add_index :events, :user_id
and then
add_index :users, :event_id
Are these assumptions correct?
source
share