Hi

I'm doing a multi-model search like this, which works absolutely fine:

        @search_results = ActsAsFerret::find( "trumpet", [Resource, Lesson,
Course],
                                    #(ferret) options
                                    { :page => 1,
                                      :per_page => 20,
                                      :sort =>
Ferret::Search::SortField.new(:name, :reverse => false)
                                    },
                                    #find options
                                    {}
                                 )

My new problem is that the results need to be restricted: basically any user
has only limited access to certain lessons, resources and courses, depending
on their shared priveleges.  I have methods to produce arrays of ids of each
that the user is allowed to see, eg

@user.allowed_lessons
  => array of ids of all lessons the user has access to

Can anyone show me how to incorporate this into my search?  I have the
feeling that i can do something with the :conditions options, which can be
passed through in the find options hash.  But i can't work it out:  i tried
this:

:conditions => ["lesson.id in (?) or course.id in (?) or resource.id in
(?)", @user.allowed_lessons, @user.allowed_courses, @user.allowed_resources]

But it doesn't work:  it says 'no such field as lesson.id in resources'.  I
feel like this should be possible - can anyone help?

thanks
max
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to