## inverse_of 是什麼？

1.讓兩個互相關聯的model可以指到同一個instance物件，在model的資料有更新時讓其他有關聯的model可以即時更新對方的資料。
2.減少資料重複查詢。

## 等等？！我跟著你的方法照著做但出來的結果怎麼會不一樣？

Every association will attempt to automatically find the inverse association and set the :inverse_of option heuristically (based on the association name). Most associations with standard names will be supported. However, associations that contain the following options will not have their inverses set automatically:
:conditions
:through
:polymorphic
:foreign_key

Good News
As of version 4.1, Rails will try to automatically set the :inverse_of option for you (pull request). Given our example with Criminal having a :belongs_to association with Prison, it will attempt to derive the inverse from the class name -- in this case :criminals based on the class Criminal. Obviously, this falls apart when the names do not match up. For example, when using :class_name or :foreign_key options on your associations. In that case, :inverse_of has to be explicitly set to the correct names, so it's still worth knowing how :inverse_of works.

## inverse_of的另一個好處

inverse_of的另一個好處就是減少重複的資料查詢

## inverse_of不會作用的情況下

There are a few limitations to inverse_of support:
They do not work with :through associations.
They do not work with :polymorphic associations.
They do not work with :as associations.
For belongs_to associations, has_many inverse associations are ignored.

inverse_of 有幾點限制：

ただし、inverse_ofのサポートにはいくつかの制限があります。
:through関連付けと併用することはできません。
:polymorphic関連付けと併用することはできません。
:as関連付けと併用することはできません。
belongs_to関連付けの場合、has_manyの逆関連付けは無視されます。