12
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

has_one throughに関して

Last updated at Posted at 2015-09-19

#Rails has_one "through"に関して

Railsの"through"に関して簡単に理解するには、簡単な英文を書いてみるのが良いと考える。
概念図から理解しようとすると難しい感覚を覚えるけど、シンプルに考えると英文らしくコードも記述されていることを理解できると思う。
基本形
A has one some through B => AはBを通じて何かを一つを持つ。

例文
A has one account through B => AはBを通じて一つのアカウントを持つ

#簡単な関連図

Class Sipplier

Supplierはaccountを持ち、accountを通じてaccout_historyを持つ。
Class Account

accountはsupplierに属していて、account_historyを一つ持つ
Class AccoutHistroy

AccountHistoryはaccoutに属している

has_one_through.png

参考サイト
http://guides.rubyonrails.org/association_basics.html

12
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?