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

**URL:** <https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213>\
**Category:** Rails\
**Created:** [February 15, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213 "2008-02-15T14:55:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barakathullah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@barakathullah](https://www.ruby-forum.com/u/barakathullah)\
**Post date:** [February 15, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213/1 "2008-02-15T14:55:01Z")

</div>

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?

\<%if @f\_len!=0%\> \<%for @f in @focus%\> \<%if @f.content\_type=='Videos'%\> \<%puts @f.content\_path%\> \<%puts @f.id%\> \<%else%\> \<%=link\_to\_remote(image\_tag(url\_for\_file\_column("f", "image\_path",:big)))%\> \<%end%\> \<%end%\> \<%else%\> NO PREVIEW \<%end%\>

---

<div class="post-metadata">

**Author:** ![barakathullah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@barakathullah](https://www.ruby-forum.com/u/barakathullah)\
**Post date:** [February 15, 2008, 3:15pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213/2 "2008-02-15T15:15:44Z")

</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?

---

<div class="post-metadata">

**Author:** ![barakathullah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@barakathullah](https://www.ruby-forum.com/u/barakathullah)\
**Post date:** [February 15, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213/3 "2008-02-15T17:24:37Z")

</div>

Thorsten M. 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

---

<div class="post-metadata">

**Author:** ![barakathullah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@barakathullah](https://www.ruby-forum.com/u/barakathullah)\
**Post date:** [February 15, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213/4 "2008-02-15T17:50:55Z")

</div>

On 15 Feb 2008, at 16:24, Bala Krishnan wrote:

> 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…

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

---

<div class="post-metadata">

**Author:** ![barakathullah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9dc877/32.png) [@barakathullah](https://www.ruby-forum.com/u/barakathullah)\
**Post date:** [February 15, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/i-want-to-specify-the-exact-root-to-play-video-files-in-my-r/129213/5 "2008-02-15T17:50:19Z")

</div>

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
