我尝试了所有可以在网上找到的组合,但总是失败。
class Profile < ActiveRecord::Base
belongs_to :user, :dependent => :destroy
has_one :match # educational matches
accepts_nested_attributes_for :match
attr_accessor :form
unless match.present?
searchable do
integer :id
string :country
string :state
end
end
end
和
Match belongs_to :profile
在 Profile 模型中,我尝试执行以下操作:
unless profile.match.exist? (does profile have a match association existing?)
.. do something
end