![](/img/trans.png)
[英]Setting if conditions to self.find_or_create_from_auth_hash(auth_hash)
[英]how much of this is auto-generated methods in Rails “User.find_or_create_from_auth_hash(auth_hash)”
在Rails“User.find_or_create_from_auth_hash(auth_hash)”中有多少是自動生成的方法。 這只是想知道這是如何工作的,以及開發人員必須做的最小編碼是什么? 也就是說,他們必須在User模型中實現什么方法? 或者他們需要一個名稱正確的方法。 所以只是想知道“查找”,“創建”,“來自”關鍵字是否是Rails特價。
取自這里: https : //github.com/intridea/omniauth
Rails通過method_missing為模型的每個屬性提供動態查找器find_by_*
, find_or_initialize_by_*
和find_or_create_by_*
。
然而, self.find_or_create_from_auth_hash(auth_hash)
方法完全不是由rails提供的,而是僅僅使用相同類型的命名約定來實現可讀性。
編輯:顯然它也提供了find_last_by_*
和find_all_by_*
。 我個人從未使用它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.