I’m developing the Order Model for a Rails application.I’m trying to represent an Order which has BillToAddressId and ShipToAddressId as the foreign keys from the Address table.
The address table is below :
create_table :addresses do |t|
t.string :country
t.string :state
t.string :city
t.string :zipcode
t.string :line1
t.timestamps
I’m a Rails newbie, so I’m not sure how to represent this in the DB/migrate for Order and Address.
It would be great if someone can guide me to build the Model and migrate script.
You can do it in follwing way
For Ruby Naming Conevention
Column name “ShipToAddressId” must be “ship_to_address_id”