我有一個基於ActiveRecord的模型,另一個基於Mogoid :: Document。有可能一起做一個協會嗎?ActiveRecord和Mogoid :: Document:關聯
例如,2種型號:
class User < ActiveRecord::Base
has_one :avatar, :dependent => :destroy
end
class Avatar
include Mongoid::Document
field :file_name
end
並獲取用戶的頭像是這樣的:
@user.avatar.file_name
謝謝!
非常感謝。你的代碼和平運作良好! – Tibal 2010-11-09 11:01:13
你可以使用Tenacity(https://github.com/jwood/tenacity)來代替黑客自己的解決方案。 – Raphael 2012-07-10 18:25:34