I want to specify the exact root to play video files in my r

Hi all,

can anyone please get me a solution for the problem i am facing in my project..

i am using this path

VALUE="#{RAILS_ROOT}/<%=@f.content_path%>"

to display and play a video in my project

where @f.content_path this variable prints a root like this

#{RAILS_ROOT}/E:/project_name/public/folder_name/id/file.mpg

but its not at all working..

if the path is like this /public/folder_name/id/file.mpg

when i embed like this.. its working.. what could be the problem?

<div> <%if @f_len!=0%> <%for @f in @focus%> <%if @f.content_type=='Videos'%> <%puts @f.content_path%> <%puts @f.id%> <OBJECT ID="MediaPlayer" WIDTH="370" HEIGHT="270" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject"> <PARAM NAME="FileName" VALUE="#{RAILS_ROOT}/<%=@f.content_path%>"> <PARAM name="autostart" VALUE="false"> <PARAM name="ShowControls" VALUE="true"> <param name="ShowStatusBar" value="true"> <PARAM name="ShowDisplay" VALUE="false"> <EMBED TYPE="application/x-mplayer2" SRC="#{RAILS_ROOT}/<%=@f.content_path%>" NAME="MediaPlayer" WIDTH="370" HEIGHT="270" ShowControls="1" ShowStatusBar="1" ShowDisplay="0" autostart="0"> </EMBED> </OBJECT> <%else%>   <%=link_to_remote(image_tag(url_for_file_column("f", "image_path",:big)))%> <%end%> <%end%> <%else%> NO PREVIEW <%end%> </div>

it's basically a bad idea, to create paths like this: "#{RAILS_ROOT}/<%=@f.content_path%>"

use the File.join method instead File.join(RAILS_ROOT, @f.content_path) this will save you a lot of trouble with missing slashes etc.

#{RAILS_ROOT}/E:/project_name/public/folder_name/id/file.mpg cant work assume a windows machine and your project is: C:\projects\myproject which is rails_root then

C:\projects\myproject/E:/project_name/public/folder_name/id/file.mpg

that's not a valid path, eg because of the two discs C: E: and the mix of slashes/backslashes

what kind of OS are you using, since the drive letters would be Windows like, but you use the slashes like for unix or mac?

Thorsten Mueller wrote:

it's basically a bad idea, to create paths like this: "#{RAILS_ROOT}/<%=@f.content_path%>"

use the File.join method instead File.join(RAILS_ROOT, @f.content_path) this will save you a lot of trouble with missing slashes etc.

#{RAILS_ROOT}/E:/project_name/public/folder_name/id/file.mpg cant work assume a windows machine and your project is: C:\projects\myproject which is rails_root then

C:\projects\myproject/E:/project_name/public/folder_name/id/file.mpg

that's not a valid path, eg because of the two discs C: E: and the mix of slashes/backslashes

what kind of OS are you using, since the drive letters would be Windows like, but you use the slashes like for unix or mac?

i am using windows xp

basically #{RAILS_ROOT} will take the path where the project will be.so in my task if i give #{RAILS_ROOT}\@f.content_path means it should show the path like \public\folder_name\id\file.mpg right? but instead it shows the path as E:\project_name\public\folder_name\id\file.mpg. how to solve this problem..

thanks, barak

Um no. RAILS_ROOT is the location on disk of your rails app, ie E:\project_name in your case. I've no idea what f and its content_path method are, but what you want to give to the user's browser is a path relative to the public/ folder in your rails app

Fred

forget about RAILS_ROOT on the browser-site. only use relative url

if i want to display an image in /public/files, i would use this: "/files/#{image.image_filename}" if the images are in /public/files

everything else will be resolved by the browser and server

so your line SRC="#{RAILS_ROOT}/<%=@f.content_path%>"

should work like this: SRC="<%=@f.content_path%>" if content_path points to the right place and does not have the leading /public