使用 ActiveRecord,如何LIKE
根据关联的属性进行查询?具体来说,我正在寻找适用于多态关联的东西。
class Invoice < ActiveRecord::Base
has_one :private_note, class_name: '::Note', as: :noteable,
conditions: {label: 'private'}
has_one :public_note, class_name: '::Note', as: :noteable,
conditions: {label: 'public'}
end
class Note < ActiveRecord::Base
belongs_to :noteable, polymorphic: true
validates :content, :presence: true
end
我想查找其中包含“友好”一词private_note
的列的发票。content