Sorry for such a slow response.

If you want to access attribute values, you can do so with the help of an 
attributes pane:

  search = City.search ‘Melbourne’
  search.context[:panes] << ThinkingSphinx::Panes::AttributesPane
  search.each { |result| result.sphinx_attributes[‘country_name’] }

The sphinx_attributes method is available via a wrapper object around each 
search result (a glaze in the TS terminology), rather than each actual city 
instance. This is discussed a bit in a blog post I wrote earlier this year:
http://freelancing-gods.com/posts/rewriting_thinking_sphinx_middleware_glazes_and_panes

— 
Pat

On 8 Nov 2013, at 7:48 pm, Максим Степанов <[email protected]> wrote:

> Hey !
> 
> I am trying to gem attributes to result set, and that's i have:
> 
> Index:
> 
>   ThinkingSphinx::Index.define :city, with: :active_record do
>     indexes :name, sortable: true
> 
>     has country(:name), as: :country_name
>     has region(:name), as: :region_name
>   end
> 
> and in model added:
> 
>   attr_accessor :country_name, :region_name
> 
> as a result country_name and regions_name filled by TS result set, not by AR 
> query
> 
> 
> 
> Is there a better way to do this ?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to