Make dynamical URL for binary data in rails

All,

I would like to do following thing: when the request reaches certain
method in a controller, I want to read binary data (e.g. an image) from
database and dynamically make up a URL (without writing that out
physically), so in the view template I could reference that URL.

How can I do that in rails?

Thanks in advance.

I would like to do following thing: when the request reaches certain
method in a controller, I want to read binary data (e.g. an image) from
database and dynamically make up a URL (without writing that out
physically), so in the view template I could reference that URL.

How can I do that in rails?

Have a controller/action with a url like: /images/show/123

And in the show() method find the image you want then use send_data().
For example:

send_data image.data, :type => image.content_type,
:disposition => ‘inline’

-philip

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