Hi Everyone,
I just started using Sphinx and its been great so far. I hit a
roadblock when trying to re-implement my permissions to ensure users
aren't returning results that they shouldn't see.
It seems the conditional support of Sphinx is much different than
standard ActiveRecord, and I am struggling with how to recreate this
scope in Sphinx. I have listed the full method below, but the most
important part I want to be able to duplicate in Sphinx is:
------------------------------------------------------
:conditions => ["
(
ISNULL(leads.group_id) AND ((leads.user_id = ? AND
leads.private = 1) OR (leads.private = 0 OR ISNULL(leads.private)))
)
OR (leads.group_id IS NOT NULL AND leads.group_id
IN(#{group_ids}))", user.id])
------------------------------------------------------
Full Method:
def self.with_permission(user)
groups = user.cached_group_ids.present? ? user.cached_group_ids :
"''"
if !user.owner? && !user.admin?
scoped(:conditions => ["
(
ISNULL(leads.group_id) AND ((leads.user_id = ? AND
leads.private = 1) OR (leads.private = 0 OR ISNULL(leads.private)))
)
OR (leads.group_id IS NOT NULL AND leads.group_id
IN(#{groups}))", user.id])
else
scoped(:conditions => [])
end
end
--
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.