我需要執行此查詢來找出MySQL將使用的下一個auto_increment值。 find_by_sql ["select auto_increment from information_schema.tables where
table_schema = ? and table_name = ? and auto_increment is not null", db_name, tbl_name
我的印象是,在ActiveRecord的該custom_finder選項意味着你有關聯的擴展名如.where和.order免費,例如: class Dog < ActiveRecord::Base
has_many :fleas, class_name: 'Flea',
finder_sql: "select fleas.* from fleas where pet_typ
在我的應用程序中,用戶has_many票。不幸的是,票據表沒有user_id:它有一個user_login(它是一個遺留數據庫)。有一天我會改變這種情況,但現在這種改變會產生太多的影響。 那麼如何通過登錄列創建「用戶has_many:tickets」關聯? 我嘗試了以下finder_sql,但它不起作用。 class User < ActiveRecord::Base
has_many