I’m using thinking sphinx, with the sphinx_select parameter to create a dynamic field, like so:
@subjects = Subject.search(sphinx_select: "*, petals < 1 or color = 2 as my_attribute")
Is there any way to access custom_attribute in the search results? For example:
@subjects.each do |s|
s.my_attribute
end
Returns
undefined method `my_attribute' for #<Subject:0x007fb25cdcdb18>
Did some digging in the thinking sphinx source and figured this out. The dynamic attributes are stored in a
matchobject, which can be accessed like so: