Hi Priya,

below are the details of tables and corresponding taggings between
streams and tags tables in taggings table.
mysql> select * from streams;
+----+------------+-----------------------------------+------------+---------+-----------+-----------+------------+------------+
| id | name       | location                          | resolution |
bitrate | framerate | codecname | created_on | updated_on |
+----+------------+-----------------------------------+------------+---------+-----------+-----------+------------+------------+
|  1 | dust.mpeg2 | E:\streams\RED_S_J_JE_In_NT.divx  | 1920x1080  |
6mbps   | 30fps     | mpeg2     | 2008-12-08 | 2008-12-08 |
|  2 | mummy.264  | E:\streams\RED_S_J_JE_In_NT.divx  | 720x480    |
4mbps   | 30fps     | h264      | 2008-12-08 | 2008-12-08 |
|  3 | hiphop.aac | na                                | na         |
na      | na        | aac       | 2008-12-10 | 2008-12-10 |
|  5 | jazz.aac   | na                                | na         |
na      | na        | aac       | 2008-12-10 | 2008-12-10 |
+----+------------+-----------------------------------+------------+---------+-----------+-----------+------------+------------+
4 rows in set (0.03 sec)

mysql> select * from tags;
+----+--------------+
| id | name         |
+----+--------------+
|  1 | mpeg2        |
|  2 | h264 720x480 |
|  3 | aac          |
+----+--------------+
3 rows in set (0.00 sec)

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

can i use the query to search with tag field like:

@streams = Stream.find(:all, :joins => "streams inner join tags as t on
          stream.id=t.id", :conditions => ['name LIKE ?',
'%'+params[:search_text]+'%'],:select => "name")

from the above query what i understand is:
it joing streams and tags table but using the "name" column of tags
table it is finding and storing the result of stream names from
streams table in @streams array.

if i a m wrong let me know ?
do i need to mention anywhere association between tables in the
corresponding models?

is there any procedure to make it work ?


thanks
srikanth






On Thu, Dec 11, 2008 at 10:46 AM, Priya Buvan
<[EMAIL PROTECTED]> wrote:
>
> If you want to search with streams field, then you have to pass all
> those parameters else its enough to pass tag field name alone.
>
> Also we can join the 2 tables so no need to give  like
> @streams=Stream.fine(:all) for tag.
>
> Do you have column heading as "name" in tag table? Check it and give the
> correct attribute name in the place of "name"
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to