polymorphic関連のモデルの検索処理をransack使って書いていて、どうやるんだ?
ってなった。答えはここにあった。
http://stackoverflow.com/questions/13077954/does-ransack-support-the-same-polymorhpic-belongs-to-associations-in-its-searche
polymorphicに関してのわかりやすい説明はこちらのサイトで。
http://shirusu-ni-tarazu.hatenablog.jp/entry/2012/11/04/173742
説明にもここの情報を使わせていただきます。
|
|
#Imageからみた検索
companyの名前のlike検索
f.text _field :imageable _of _Company _type _name _cont
#Imageからみた検索
userの名前のlike検索
f.text _field :imageable _of _User _type _name _cont
polymorphic名 of 検索したいクラス名 + type + 検索対象列 + 条件
で検索できるみたい。