Problems with tags_as_taggable


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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs