看板 Ruby 關於我們 聯絡資訊
感謝先前大大們的回覆,小弟受惠良多! 這次又要來請教相關問題,我有兩個model之間是用 A belongs_to B , foreign_key: :B_id B has_may As ---在 A.rb 裡面--- def self.search(search) if search where('name LIKE?',"%#{search}%") (這裡我可以搜尋model A裡面的欄位資料) elsif search (該如何透過B_id去搜尋存在B裡面的相關欄位?) else all end 再次感謝! -- 果果 / 錄音混音後期製作 / 電腦繪圖珠寶設計 http://www.thereveriestudio.com/ http://www.michaeljohnbridal.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 98.178.243.164 ※ 文章網址: https://www.ptt.cc/bbs/Ruby/M.1450733563.A.E81.html
nyc0125: https://goo.gl/FVKsdF 12/23 02:39
little78926: 大感謝! 12/23 03:58