Hi Arif
I recommend not skipping the :through associations in index definitions -
ActiveRecord creates better joins this way:
indexes beneficiary_datum.activity_description_original.text_value,
:as => :activity_description_original
But that probably doesn't avoid the error you're seeing. Because Ruby objects
cannot be referred to by Sphinx when indexing SQL-based indices, it's not
possible to have that Proc evaluated. Is there some way you can translate the
Proc to a standard SQL string, perhaps using functions from the database to get
the year? If it's just the current year, then it should be a simple matter, but
if there's more complexity involved, then I guess it's a little tricky.
Cheers
--
Pat
On 09/01/2013, at 7:29 PM, Arif wrote:
> Hey all,
>
> Hoping for some direction/thoughts. I have a model Beneficiary which has the
> following associations (the first one is the impt one that is bombing with
> sphinx):
> has_one :beneficiary_datum, :conditions => Proc.new { "year =
> #{self.current_data_year}" }
>
> has_one :activity_description_original,
> :through => :beneficiary_datum,
> :source => :beneficiary_datum_entries,
> :conditions => {:entry => 't3010_activity_description_original'},
> :select => 'text_value'
>
> I'd like to use that association in my sphinx index like so:
> indexes activity_description_original.text_value, :as =>
> :activity_description_original
>
> When attempting to generate the index config it fails with this:
> undefined local variable or method `current_data_year' for
> #<ActiveRecord::Associations::JoinDependency::JoinAssociation:0x007fcfaa780998>
>
> Is it possible to use the model attribute as a condition like I'm trying to
> do?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/thinking-sphinx/-/nowJ1hswtPIJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.