# Problems with tags\_as\_taggable

**URL:** <https://www.ruby-forum.com/t/problems-with-tags-as-taggable/103688>\
**Category:** Rails\
**Created:** [May 9, 2007, 10:16am UTC](https://www.ruby-forum.com/t/problems-with-tags-as-taggable/103688 "2007-05-09T10:16:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [May 9, 2007, 10:16am UTC](https://www.ruby-forum.com/t/problems-with-tags-as-taggable/103688/1 "2007-05-09T10:16:37Z")

</div>

Hello

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”  
end

class TblTag \< ActiveRecord::Base  
set\_primary\_key :tag\_id  
end

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?  
Thanks
