ruby on rails - Relationships with different name than the standard on ActiveRecord migrations -
i have generated 3 models (rails generate model): professionals, professionalcouncils , states. professionals table must have reference states table, column should named professional_council_state_id instead of state_id.
how can achieve in migration code?
here how right now:
class createprofessionals < activerecord::migration def change create_table :professionals |t| t.string :name, limit: 70 t.string :number, limit: 15 t.references :professional_council, index: true t.references :occupation_code, index: true t.timestamps null: false end add_foreign_key :professionals, :professional_councils add_foreign_key :professionals, :occupation_codes end end class createstates < activerecord::migration def change create_table :states |t| t.string :description, limit: 40, null: false t.string :abbreviation, limit: 2, null: false t.integer :ibge_code t.timestamps null: false end end end
Comments
Post a Comment