How to implement tags using acts_as_taggable_on_steroids?


#1

hi all:

im using rails 2.0 on windows:
i instaled acts_as_taggable_on_steroids
i have a controller and a model for streams table.
i did migration for tag support also

everything is working fine i.e if i run

http://localhost:3000/streams

i am able to enter the data in to streams table from web index page.

on ruby console i have tried like:

I have faced below problems like:

if I want to find the data from table with tag name xx I m getting the
same result for all other tags also.(my table contains columns
like:name,resolution,framerate,codecname and tags table having the tags
as:resolution,name,codecname,omap,hd)

Example:
Stream.find_tagged_with(‘resolution’)
=> [#<Stream id: 4, name: “mummy.mpeg2”, resolution: “352x240”,
codecname: “mpeg2”, framerate: “30fps”, created_at: “2008-12-04
16:25:41”, updated_at: “2008-12-04 16:48:47”>]

Stream.find_tagged_with(‘codecname’)
=>[#<Stream id: 4, name: “mummy.mpeg2”, resolution: “352x240”,
codecname: “mpeg2”, framerate: “30fps”, created_at: “2008-12-04
16:25:41”, updated_at: “2008-12-04 16:48:47”>]

Below are the details of my table entries :

mysql> use stdb_development;
Database changed
mysql> show tables;
±---------------------------+
| Tables_in_stdb_development |
±---------------------------+
| schema_info |
| streams |
| taggings |
| tags |
±---------------------------+
4 rows in set (0.00 sec)

mysql> select * from tags;
±—±-----------+
| id | name |
±—±-----------+
| 1 | codecname |
| 2 | resolution |
| 3 | omap |
| 4 | hd |
| 5 | omap hd |
| 6 | omap,hd |
±—±-----------+
6 rows in set (0.00 sec)

mysql> select * from taggings;
±—±-------±------------±--------------+
| id | tag_id | taggable_id | taggable_type |
±—±-------±------------±--------------+
| 1 | 1 | 4 | Stream |
| 2 | 2 | 4 | Stream |
| 3 | 3 | 4 | Stream |
| 4 | 4 | 4 | Stream |
| 5 | 5 | 4 | Stream |
| 6 | 6 | 4 | Stream |
±—±-------±------------±--------------+
6 rows in set (0.00 sec)

mysql> select * from streams;
±—±------------------±-----------±----------±----------
±--------------------±--------------------+
| id | name | resolution | codecname | framerate |
created_at | updated_at |
±—±------------------±-----------±----------±----------
±--------------------±--------------------+
| 1 | dust.mpeg2 | 1920x1080 | mpeg2 | 30fps |
2008-12-04 16:23:23 | 2008-12-04 16:23:23 |
| 2 | amelie.264 | 720x480 | h264 | 25fps |
2008-12-04 16:23:58 | 2008-12-04 16:23:58 |
| 3 | davincieffect.aac | NA | aac | NA |
2008-12-04 16:24:46 | 2008-12-04 16:24:46 |
| 4 | mummy.mpeg2 | 352x240 | mpeg2 | 30fps |
2008-12-04 16:25:41 | 2008-12-04 16:48:47 |
±—±------------------±-----------±----------±----------
±--------------------±--------------------+
4 rows in set (0.00 sec)

1)so my doubt is tag name can be anything or it shoud be the one of
the column name of the table?
2)to do the same by accepting the tag name as text box entry and i
need to find(search) the data of perticular tag.How can i proceed
that?

any one can give me an idea whether i am doing the wrong or smthing
else?

thanks