What belongs_to and their counterparts does is create a method to access an existing relationship, the actual relationship is made in the tables themselves by adding model_id columns, for instance:
class User < ActiveRecord::Base
has_one :address
end
class Address < ActiveRecord::Base
belongs_to :user
end
# Shows the address whose addresses.user_id =
users.id User.last.address
# Shows the user whose
users.id = addresses.user_id
Address.last.user
If you don't need to access the relationship in the Address model just delete `belongs_to :user`:
class Address < ActiveRecord::Base
end
User.last.address # Shows address
Address.last.user # NoMethodError: undefined method `user'