how to use youtube-g ruby gem? -
new rails , trying youtube-g work... having difficult time passing users search form_tag controller.. example:
- user lands on page, enters - tiger videos - in text_field_tag
 - controller takes - tiger videos - , searches
 user lands on page displaying results...
user lands on page, enters query
index.html.erb
<%= form_tag(youtube_path) %>      <%= label_tag(:q, "search for:") %>      <%= text_field_tag(:wth) %>      <%= submit_tag("search") %>     <% end %>   --
- controller takes query , searches
 
youtubecontroller.rb
class youtubecontroller < applicationcontroller def search   require 'youtube_g'   client = youtubeg::client.new client.videos_by(:query => params[:wth]) end end   --
my routes file:
actioncontroller::routing::routes.draw |map| map.search “search”, :controller => “youtube”   i havn´t got step 3 yet..
what want page text box , submit button, , when user enters text , submits, brought new page renders 10 youtube results. appreciated!!!
search.html.erb
 <%= form_tag(:action => "search") %>        <%= label_tag(:q, "search for:") %>        <%= text_field_tag(:wth) %>        <%= submit_tag("search") %>    <% end %>   youtubecontroller
require 'youtube_g' class youtubecontroller < applicationcontroller   def index            end    def search       if request.post?      client = youtubeg::client.new      @youtube = client.videos_by(:query => params[:wth],:per_page => 10)               render :action => :index     end    end end   index.html.erb
<% @youtube.videos.each |video| %>    <%= video.title %> <% end %>   routes.rb
 map.resources :youtube, :collection => { :search => :get }      
Comments
Post a Comment