Forum: Ruby on Rails Problems with tags_as_taggable

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.
E10d95b17460b1a851700f295e0dac6a?d=identicon&s=25 Chamnap Chhorn (chamnap)
on 2007-05-09 10:16

I need help from you all. I have 3 tables: tbl_restaurants, tbl_tags,
and tbl_res_tags. tbl_restaurants has 3 fields: res_id, name,
description. tbl_tags has tag_id and name. tbl_res_tags has tag_id and
res_id. So, tbl_restaurants has a Model "TblRestaurant". tbl_tags has a
Model "TblTag". tbl_res_tags has a Model "TblResTag". So, I define:

class TblRestaurant < ActiveRecord::Base
  set_primary_key :res_id
  acts_as_taggable :tag_class_name => "TblTag",
                   :join_class_name => "TblResTag",
                   :join_table => "tbl_res_tags",
                   :foreign_key => "res_id",
                   :association_foreign_key => "tag_id"

class TblTag < ActiveRecord::Base
  set_primary_key :tag_id

When I write:

res = TblRestaurant.find(1).tag("AA BB CC")

In tbl_res_tags, there are 3 records. But, the tag_id has "0" value and
res_id has "1" value.

So, what 's wrong with my code? Can anyone solve this problem?
This topic is locked and can not be replied to.