If anyone could help me figure this out, I’d appreciate it alot.
I’m playing around with the Scriptaculous autocomplete function, which
per the demonstration on their page looks like this in the controller:
@results = People.find(:all, :conditions => [ 'LOWER(fullname) LIKE ?','%'
value.downcase + ‘%’ ],
:order => ‘fullname ASC’,
:limit => 8)
render :partial => ‘contacts’ and return
There are three database tables…
People - id, fullname, email
(Stores the contact information of the people)
Access - id, people_id, user_id
(If a user has access to particular contact, it records that contact and
that user’s id in a new row)
User - id, username, password, etc.
(Stores the user account data)
In short, not all users get access to the same contacts although there
will be some overlap, which prevents me from assigning any particular
contact simply to one user alone.
How could this controller be modified so that users only see contacts
that they have access to? Ideally, this would be because there is a
matching pair in the Access table. Once the system finds a match between
the user input and the database in question, it then checks to make sure
that there is a row in the Access table that has both the people_id and
user_id necessary. If not, discards it.
Thank you for your time!