Bob Anderson Thu Nov 16 08:51:18 -0500 2017

Subject: has many through question

Hi,

I have three models:

Bookmark (with fields: id, url)
ContentTag (with fields: model, model_id, tag_id)
Tag (with fields: id, taglabel)

how do I define the static $has_many array so I have an array tags in model Bookmarks.

You can find all tags for a bookmark by checking model ContenTag with model = "BOOKMARK" and model_id = id from tabel Bookmark. And then you can get the Tag using ContentTag->tag_id = Tag->id.

I have tried several ways but can't seem to get it right.

Does anyone have a simple example for this type of stuff? Of is it impossible since I have a foreign_key option in the contenttag association?