Displaying a textfile inline

My application utilizes the file_column plugin
to allow the uploading of text files (and only
text files) to the server. What I would like to
be able to do is when the “show” view template is
rendered for a particular record, instead of providing
a link to the particular textfile for the record, have
it display the actual contents of the file inline
along with the rest of the fields.

If the files were images it would be trivial to get
them to display inline by wrapping the file_column-ized
field in some HTML. However since the field contains
only a pointer to the file’s location in the filesystem
I’m not sure how to get the contents out of the text file
and in the view.

Right now I have the text file appearing as a link which,
when clicked, opens a popup with the contents inside of it.
An ok compromise, but I really would like to get it all
on one page.

Thanks in advance for any help!

On Fri, 2006-10-27 at 14:39 +0000, Dave Davidson wrote:

them to display inline by wrapping the file_column-ized
Thanks in advance for any help!


this is code that I use in one of my controllers that can do this…

@ray_message = File.file?("/var/www/html/motd/ray.txt") ? arr =

IO.readlines("/var/www/html/motd/ray.txt") : “Nothing at this time”

Craig

Craig W. <[email protected]…> writes:

this is code that I use in one of my controllers that can do this…
ray_message = File.file?("/var/www/html/motd/ray.txt") ? arr =
IO.readlines("/var/www/html/motd/ray.txt") : “Nothing at this time”

You sir, are a genius. Worked like a charm. Many thanks!

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