1

次のように、ユーザー入力を配列として受け取るフィルタリングアルゴリズムを作成しています

@keywords = [['undergrad','grad'],['SAT', 'GPA'], ['Stanford']]

データベースのビデオテーブルなど、テーブルをクエリします。テーブルには、コンマで区切られたいくつかのタグを含む文字列フィールドがあります。

ロジックは次のとおりです。

In all videos, if the tags include "undergrad", "grad", returned those videos;
In the returned videos, if the tags include "SAT", "GPA", returned those videos;
In the returned videos, if the tags include "Stanford", returned those videos;

Rails での実装に関するヘルプはありますか?

4

1 に答える 1

0

Postgres を使用している場合は、where ステートメントでhttp://www.postgresql.org/docs/current/static/functions-matching.htmlのようなことを行うことができます。

または MySQL https://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

于 2013-08-06T02:16:09.780 に答える