How to create a search bar for searching youtube videos using youtube_it

9 views
Skip to first unread message

Wilson Wilson

unread,
Apr 30, 2014, 11:59:19 AM4/30/14
to rubyonra...@googlegroups.com
I've been able to set things up to display a result of queries using
youtube_it gem my current code for fetching that data is

def index
$client = YouTubeIt::Client.new(:dev_key =>
"AI39si6i1NPgrU35e6xxRgvtGclAdH9pHnwefuUbHKZmKJutqDNvTZwY3PawefEY9rarYzmpN__UuMH19bAny0-retoMa8IsNILlDA")
@videos = $client.videos_by(:tags => ['funnyvideo'])
end


The thing is that I want to allow the user to input what they want to
search instead of me putting in funny video, I want a search bar that
allows users to type in their tags.


My current search bar looks something like this
<% form_tag videos_path, :method 'get' do %>
<%= text_field_tag :search %>
<%= submit_tag "search" %>
<% end %>


How can I pass in whatever the user type into the search bar to fetch
the youtube tags?


Thanks

--
Posted via http://www.ruby-forum.com/.

yassine sania

unread,
May 1, 2014, 5:29:53 AM5/1/14
to rubyonra...@googlegroups.com
Whatever the user passes you gonna find it in the params hash so in your case:

@videos = $client.videos_by(:tags => params[:search])

Reply all
Reply to author
Forward
0 new messages