Combining Association Scopes With ‘OR’ & Searching On Associations

17 views
Skip to first unread message

MaggotChild

unread,
Jan 12, 2010, 2:54:25 PM1/12/10
to Searchlogic
I'm trying to use ORs with 2 named scopes on an association. This does
not seem possible.

Relation:
Spot.has_one :details

Named scoped:
Details.named_scope :created_by, proc { |login| { :conditions =>
[ 'ASEXT.dbCreateBy = ?', login ] } }
Details.named_scope :last_modified_by, proc { |login| { :conditions =>
[ 'ASEXT.dbModBy = ?', login ] } }


>> Spot.details_last_modified_by('bill').size
=> 0
>> Spot.details_created_by('bill').size
=> 15
>> Spot.details_last_modified_by_or_details_created_by('bill').size
NoMethodError: undefined method `details_last_modified_by_' for
#<Class:0xb767eec4>
...
I've also tried the seemingly obvious wrong way:

>> Spot.details_last_modified_by_or_created_by('bill').size
Searchlogic::NamedScopes::OrConditions::UnknownConditionError: The
condition 'created_by' is not a valid condition, we could not find any
scopes that match this.

Variants of: Spot.details_last_modified_by_or_details_created_by_equals
('bill') also fail.

Is it also not possible to search on association conditions?

>> Spot.search :details_ProgramType => 'SERIES'
Searchlogic::Search::UnknownConditionError: The details_ProgramType is
not a valid condition. You may only use conditions that map to a named
scope

>> Details.search :ProgramType => 'SERIES'
=> #<Searchlogic::Search:0xb7494a64 @klass=Details(.....

Reply all
Reply to author
Forward
0 new messages