Access to model instance in searchable block

21 views
Skip to first unread message

Matt Lins

unread,
May 21, 2012, 5:25:41 PM5/21/12
to Sunspot
Hi,

Maybe there is a better way to do this, but my Properties model needs
to be sorted differently based on the currently logged in Agent.
Hopefully, you can see what I'm trying to accomplish by the following
code (the currently logged in Agent will always be last in the sort
string of agents assigned to the property). My idea was to build a
separate sort index for each Agent that is associated with the
Property - then use that specific sort index in my controller when
searching. In order to do so, I need access to my Property instance
inside the searchable block. Here is the code that doesn't work:

https://gist.github.com/2764759

Any ideas on to pull something like that off?

Thanks,

Matt

Andy Lindeman

unread,
May 21, 2012, 10:38:31 PM5/21/12
to ruby-s...@googlegroups.com
On Mon, May 21, 2012 at 4:25 PM, Matt Lins <matt...@gmail.com> wrote:
> Any ideas on to pull something like that off?

Could you just stick all of the values in one multiple: true string field?

--
Andy Lindeman
http://www.andylindeman.com/

Matt Lins

unread,
May 22, 2012, 2:46:54 PM5/22/12
to Sunspot
From the documentation:

Whether the field should index multiple values (the method/block used
to generate the data returns an Array). Multiple-value fields cannot
be used for sorting, for reasons that are fairly obvious when you
think about it.

Just to clarify, I'm creating these strings for sorting based on the
current user that's logged in (the current user is always at the end
of the associated users string - which is an option for sorting).

Can :multiple somehow work for me Andy?

On May 21, 9:38 pm, Andy Lindeman <alinde...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages