Associations makes common operations simpler and easy in code and removes unnecessary complexities.It ties objects together using foreign keys. Associations creates a connection between two models.
here is the code which shows Association example:
class Customer < ActiveRecord::Base
has_many :orders, dependent: :destroy
end
class Order < ActiveRecord::Base
belongs_to :customer
end
0 Comment(s)