hi priya,
thanks for your reply,
but what you are telling is similar to:
@streams = Stream.find( :all,:conditions => [( ["(LOWER(name)
LIKE ?)"] * terms.size ).join(" AND "),* terms.flatten] )
with this i am able to search the table for any one column.
my query is :
1)i have to search with any column name
eg:name or codecname or resolution or frame rate
to do this i updated my query like:
@streams = Stream.find( :all,:conditions => [( ["(LOWER(name) LIKE ?),
(LOWER(resolution) LIKE ?),(LOWER(codecname) LIKE ?),(LOWER(framerate)
LIKE ?)",search_text,.search_text,search_text,search_text] *
terms.size ).join(" AND "),* terms.flatten] )
but i could not get the output throwing mysql erros.
2)i need to search with the tagname instead of stream table entries to
do this updated my query like;
@streams = Stream.find_tagged_with(:all, :conditions => [( ["(LOWER
(name) LIKE ?)"] * terms.size ).join(" AND "), * terms.flatten ] )
if i enter a tagname mpeg2 in search box it shold give reult as:
dust.mpeg2
but i did not see any result on webpage and no error.So i have checked
in development.log
searching is happening but it could not able to print on page.
log file details:
Processing StreamsController#index (for 127.0.0.1 at 2008-12-10
15:19:35) [GET]
Session ID:
BAh7BzoMY3NyZl9pZCIlYTg0NGU1YTNiZGMxNzEzYzEwYTdhMWRiOWFmNmFh
%0AMDgiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh
%0Ac2h7AAY6CkB1c2VkewA%3D--d23cab72ea46e47489ac826945b29bbc3431a039
Parameters: {"action"=>"index", "controller"=>"streams"}
[4;36;1mStream Load (0.000000) [0m [0;1mSELECT * FROM `streams`
[0m
Rendering template within layouts/streams
Rendering streams/index
[4;35;1mStream Columns (0.000000) [0m [0mSHOW FIELDS FROM
`streams` [0m
[4;36;1mStream Load (0.000000) [0m [0;1mSELECT * FROM `streams`
WHERE (`streams`.`id` = 1) [0m
[4;35;1mTag Load (0.000000) [0m [0mSELECT tags.* FROM tags INNER
JOIN taggings ON tags.id = taggings.tag_id WHERE
((taggings.taggable_type = 'Stream') AND (taggings.taggable_id = 1))
[0m
[4;36;1mStream Load (0.000000) [0m [0;1mSELECT * FROM `streams`
WHERE (`streams`.`id` = 2) [0m
[4;35;1mTag Load (0.000000) [0m [0mSELECT tags.* FROM tags INNER
JOIN taggings ON tags.id = taggings.tag_id WHERE
((taggings.taggable_type = 'Stream') AND (taggings.taggable_id = 2))
[0m
Completed in 0.03100 (32 reqs/sec) | Rendering: 0.01500 (48%) | DB:
0.00000 (0%) | 200 OK [http://localhost/streams]
thanks
srikanth
On Dec 10, 1:43 pm, Priya Dharsini <[EMAIL PROTECTED]>
wrote:
> @stream = Stream.find(:all, :conditions => ['title LIKE ?',
> '%'+params[:search_text]+'%'])
>
> try with this code
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---