Forum: Ruby on Rails Add'l filtering on HABTM

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brian A. (Guest)
on 2006-04-10 23:08
I have a table "keywords" with a HABTM relationship with "files" in a
legacy MySQL db.

I can find all of the files associated with a keyword in Rails. These
files can be on any of 4 volumes. However, users can have restrictions
on which volumes they have access to, so after returning the file list,
I need to filter it against an string array of allowable volumes for
that user. There is no permissions table in the db I can chack against,
and I can't add tables.

Can this be done in Rails? I was hoping for something in a dynamically
constructed :conditions clause.
Otherwise, I would have to do array manipulation in Ruby with
potentially large arrays.
Brian A. (Guest)
on 2006-04-11 19:56
Yes, of course it works. No mention of other types of SQL constructions
in the Agile book, but a little digging online found examples.

:conditions => [path LIKE :path, {:path => "some_path_fragment%"}]
This topic is locked and can not be replied to.