Variables in routes.rb?

Hi everyone,

The title is based on what I think is the solution to this problem:

I need to have files available without, as far as the client is
concerned, server processing. I know how to make
http://www.myapp.com/flv/get/30 and it will return a flv file. The
browser knows how to handle that, no problem, but some programs, like
Flash, don’t.

I can’t tell Flash to play http://www.myapp.com/flv/get/30 because it
won’t know how to accept it.

This is what I thought the solution would be, but if you know of other
ways to do this, I’d greatly appreciate your help. It’s based on a
solution to a similar problem I found here: http://tinyurl.com/ylnyzk

How do I assign “variables” in routes.rb? For example:

map.connect ‘/flv/get/.flv’, :controller =>
‘flv’, :action => ‘get’, :id =>

I hope that was clear. Thanks!

Ramon Miguel M. Tayag

How do I assign “variables” in routes.rb? For example:

map.connect ‘/flv/get/.flv’, :controller =>
‘flv’, :action => ‘get’, :id =>

I am not sure if I understand the problem here.
I think routes.rb comes with this:
map.connect ‘:controller/:action/:id.:format’

which should take care of your case - request to flv/get/30.flv will
be handled by flv_controller’s action ‘get’ which will have access to
params[:id] .

Of course you can have your own route like

map.connect ‘flv/get/:movie_id.flv’

and in your controller retrieve :movie_id with params[:movie_id]

Regards,
Rimantas

http://rimantas.com/

It seems the problem was in the way the server would send the file to
client. We used to use generate_file but it didn’t work. I thought
the problem lay in the fact that there was no extension.

We played around with it a bit more and tried send_file and the Flash
player could read it just fine.

Thanks Rimantas!

On 3/2/07, Ramon Miguel M. Tayag [email protected] wrote:

Great, that sounds like it’ll do the job.

Thanks - I’ll try it when I wake up tom! Will post here my progress.


Ramon Miguel M. Tayag

Great, that sounds like it’ll do the job.

Thanks - I’ll try it when I wake up tom! Will post here my progress.
Thanks!

On 3/1/07, Rimantas L. [email protected] wrote:

which should take care of your case - request to flv/get/30.flv will
Rimantas

http://rimantas.com/


Ramon Miguel M. Tayag

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs