# Variables in routes.rb?

**URL:** <https://www.ruby-forum.com/t/variables-in-routes-rb/87267>\
**Category:** Rails\
**Created:** [March 1, 2007, 11:00am UTC](https://www.ruby-forum.com/t/variables-in-routes-rb/87267 "2007-03-01T11:00:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [March 1, 2007, 11:00am UTC](https://www.ruby-forum.com/t/variables-in-routes-rb/87267/1 "2007-03-01T11:00:50Z")

</div>

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](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](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](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

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [March 1, 2007, 12:22pm UTC](https://www.ruby-forum.com/t/variables-in-routes-rb/87267/2 "2007-03-01T12:22:05Z")

</div>

> 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/](http://rimantas.com/)

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [March 2, 2007, 9:44am UTC](https://www.ruby-forum.com/t/variables-in-routes-rb/87267/3 "2007-03-02T09:44:50Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [March 1, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/variables-in-routes-rb/87267/4 "2007-03-01T17:28:57Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## which should take care of your case - request to flv/get/30.flv will Rimantas
> 
> [http://rimantas.com/](http://rimantas.com/)

–  
Ramon Miguel M. Tayag
