Using custom named scopes to do ORy things

10 views
Skip to first unread message

DerNalia

unread,
Aug 4, 2010, 4:42:09 PM8/4/10
to Searchlogic
I tried using a named scope:
In the same method, I have this:

Object.named_scope :public_and_my_private, :conditions =>
"user.id == #{current_user.id} or visibility == #{Shared::PUBLIC}"

and


@search = @search.search(:public_and_my_private)


but both the original @search.all and the new @search.all yield the
same number of results. (The new @search should have 2 Objects)


I found on the search logic git page that it shows how to use OR. Not
a very good example, imo, as I can't get it to work.

@search.visibility_is(PUBLIC)
@search.visibility_or_user_id_is(current_user.id)

The above returns nothing.


If there is something similar to


@search.user_id_is(current_user).or_visibility_is(PUBLIC)

that would be awesome.
Reply all
Reply to author
Forward
0 new messages