Rails Association checker


使用說明:

目前提供belongs_to、has_many、has_many :through三種關聯類型驗證,可於下方選擇類型。

belongs_to、has_many允許使用關鍵字為:class_name、foreign_key、primary_key,其他的可能會報錯。
has_many :through允許使用關鍵字為through、source,其他的可能會報錯。

驗證方式有兩種選項:
1. 輸入Model內設定,DB schema留空。按下確認鍵後會依照Rails慣例提供對應的資料(has_many :through不適用)
2. 輸入所有資料,按下確認鍵後會依照Rails慣例,標示出符合慣例的、需要修改的

註1:單複數轉換的程式碼是抄來的,不一定能全部都對。可以前往這個頁面事先確認。
註2:做了點關於Rails關聯慣例的筆記,可參考連結


請選擇關聯類型


Model內設定(belongs_to)

Class < ActiveRecord


end

DB schema

belongs_to設定

自己的外鍵:

對方的model name:

對方的主鍵:

has_many / has_many :through設定

自己的主鍵:

對方的model name:

對方的外鍵:

結果