Skip to content

Instantly share code, notes, and snippets.

@salbito
Forked from anonymous/gist:618906
Created October 10, 2010 03:43
Show Gist options
  • Save salbito/618912 to your computer and use it in GitHub Desktop.
Save salbito/618912 to your computer and use it in GitHub Desktop.
search.html.erb
<%= form_tag(:action => "search") do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:wth) %>
<%= submit_tag("Search") %>
<% end %>
--
youtube_controller.rb
require 'youtube_g'
class YoutubeController < ApplicationController
def index
end
def search
client = YouTubeG::Client.new
@videos = client.videos_by(:query => params[:wth],:per_page => 1)
render :action => :index
end
end
--
index.html.rb
<%= @videos.inspect %>
@salbito
Copy link
Author

salbito commented Oct 10, 2010

application.rb

require 'youtube_g'

youtube_controller.rb

class YoutubeController < ApplicationController

    def index
    end

    def show
        @client = Youtube::Client.new
        @videos = client.videos_by(:query => params[:yt_search_query], :limit => 1)
    end

end

index.html.erb

<%= form_tag(:action => "show") do %>
    <%= label_tag(:) %>
    <%= text_field_tag(:yt_search_query) %>
    <%= submit_tag("Search") %> 
<% end %>

show.html.erb

<%= form_tag(:action => "show") do %>
    <%= label_tag(:) %>
    <%= text_field_tag(:yt_search_query) %>
    <%= submit_tag("Search") %> 
<% end %>

@videos.each do |v|
    v.url
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment