Search code examples
activerecordrake

adding index in rails


I

I have added has_many and belongs_to after running rake db:migrate. I added these associations and again rake db:migrate. No index was generated. Can you please tell me why is that?

Below are my associations

class Developer < ActiveRecord::Base has_many :evaluations has_many :final_scores belongs_to :supervisor end

class Evaluation < ActiveRecord::Base belongs_to :developer belongs_to :supervisor end

class FinalScore < ActiveRecord::Base belongs_to :developer end

class Supervisor < ActiveRecord::Base has_many :developers has_many :evaluations :through => :developers end


Solution

  • Have a look at the official rails guide on this subject: http://edgeguides.rubyonrails.org/association_basics.html#the-has-many-association

    There you can see that you need to change the generated migration file and add the field by yourself.