Jett Hsieh
Jett Hsieh

Reputation: 3159

Access assets in outside from RoR project folder

Suppose I have an audio file in ~/auido/test.ogg and I want to create a link associated to it in my RoR, which in ~/project/my_app.

Is it possible?

Upvotes: 0

Views: 172

Answers (3)

Matthew Rudy
Matthew Rudy

Reputation: 16834

As a slight modification to @Skydreamer's answer.

If you have an audio folder you want to serve (eg. ~/audio)

just symlink this to public.

ln -s ~/audio ~/project/my_app/public/

then you can access any file in ~/audio via the url "/audio"

Upvotes: 1

Jett Hsieh
Jett Hsieh

Reputation: 3159

I found I could create a controller which read .ogg file like

@test_ogg=File.open(~/audio/test.ogg,"rb").read

and put it in html.erb like

<%=raw(@test_ogg)%>

And then I could access it from a url link "http://test.com/audio/01".

Thanks!

Upvotes: 0

Cydonia7
Cydonia7

Reputation: 3826

If you're using linux, you can use ln command like this : ln -s ~/audio/test.ogg ~/project/my_app/assets/sounds/test.ogg

Upvotes: 1

Related Questions