Hi Benjamin
Sphinx scopes only apply to Sphinx fields and attributes - and you don't have
the status as an attribute.
has instructor_profile.status, :as => :status
And then your scope should look like the following:
sphinx_scope(:active_instructors) do
{:with => {:status => 1}}
end
Cheers
--
Pat
On 02/02/2011, at 6:53 AM, Benjamin Moses Lieb wrote:
> I am trying to define a scope whose condition is on an associated
> model. In plain English I want to list all users in my site that are
> active instructors. I will also want a scope for inactive instructors.
> Can someone please help me with the syntax of the scope condition?
>
> define_index do
> indexes :username, :sortable => true
> indexes :first_name, :sortable => true
> indexes :last_name, :sortable => true
> indexes instructor_profile.bio #referreing to the association will
> force a JOIN in the sql so that the table name can be used as a
> condition in the :where
> where "instructor_profiles.instructor_id IS NOT NULL"
> has :created_at
> end
> sphinx_scope(:active_instructors) do
> {:conditions => {'instructor_profile.status' => 1}}
> end
>
>
> I've also tried this, which also hasn't worked:
>
> {:conditions => {'instructor_profiles.status' => 1}}
>
> --
> 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.
>
--
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.