Prasad B.
2011-May-22 10:47 UTC
Youtube_model pluign issue "can''t convert nil into String"?
Hi ,
i want uplaod videos using youtube model pluign and youtube api. i
follow all instructions . But i am getting below error .
Error:
----------
can''t convert nil into String
app/controllers/videos_controller.rb:42:in `create''
Request
Parameters:
{"commit"=>"Create",
"authenticity_token"=>"bb4gNcdtGNNo4fsCJt/vZxEYP+7B7L3NtTD2OmmWsJU=",
"utf8"=>"\342\234\223",
"vid"=>{"category"=>"Film",
"auth_sub"=>"1/-jwDoI3pYKaS4JUdoTXjNjWezgjDQ4mStDXZy1nk8ag",
"title"=>"sdgsdgds",
"token"=>"1/-jwDoI3pYKaS4JUdoTXjNjWezgjDQ4mStDXZy1nk8ag",
"description"=>"",
"file"=>#<ActionDispatch::Http::UploadedFile:0x6712638
@content_type="video/x-msvideo",
@headers="Content-Disposition: form-data; name=\"vid[file]\";
filename=\"butterfinger-surprise.avi\"\r\nContent-Type:
video/x-msvideo\r\n",
@original_filename="butterfinger-surprise.avi",
@tempfile=#<File:C:/DOCUME~1/Anu/LOCALS~1/Temp/RackMultipart20110522-5484-1s9c9tt-0>>,
"keywords"=>""}}
Here my code:
-------------------
In controller:
-------------------
def authorise
client = GData::Client::DocList.new
if params[:token]
client.authsub_token = params[:token] # extract the single-use token
from the URL query params
session[:token] = client.auth_handler.upgrade()
client.authsub_token = session[:token] if session[:token]
end
redirect_to videos_path
end
def new
@categories ||= Vid.video_categories
@video = Vid.new(:token => session[:token])
end
def create
@video = Vid.new(params[:vid])
if !@video.save
render :action => :new
end
end
In views:
------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta content="text/html; charset=iso-8859-1"
http-equiv="Content-Type"
/>
</head>
<body bgcolor="#FFFFFF">
<%= form_for(@video, :url => {:action => "create"
,:controller
=>"videos"}, :html => {:multipart => true}) do |f| %>
<% if @video.errors.any? %>
<h2><%= pluralize(@video.errors.count, "error") %>
prohibited this user
from being saved:</h2>
<ul>
<% @video.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
<% end %>
<%= f.hidden_field :auth_sub, :value => session[:token] %>
<%= f.text_field :token , :value => session[:token] %>
<br/>
<%= f.label :title %>
<%= f.text_field :title %>
<br/>
<%= f.label :description %>
<%= f.text_area :description, :rows => 6 %>
<br/>
<%= f.label :category %>
<%= f.select :category, @categories %>
<br/>
<%= f.label :keywords %>
<%= f.text_field :keywords %>
<br/>
<%= f.label :file %>
<%= f.file_field :file %>
<br/>
<%= f.submit ''Create'' %>
<% end %>
</body>
</html>
In model:
-------------
class Vid < YouTubeModel::Base #inherits from ActiveResource::Base
self.default_youtube_options= {:itemPerPage => 10}
schema do
attribute :title, :string
attribute :description, :string
attribute :keywords, :string
attribute :category, :string
attribute :file, :string
attribute :token, :string
end
validates_presence_of :title
validates_presence_of :token #needed on remote crud operation
validates_presence_of :file, :if => Proc.new{|vid| vid.new? }
end
Vid.top_rated(:startIndex => 10, :itemPerPage => 30)
Let me know any one about this error .
Thanks in advance.
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Prasad B.
2011-May-24 12:18 UTC
Re: Youtube_model pluign issue "can''t convert nil into String"?
Hi,
It is urgent let me know any one ........
Thanks in advance
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.