Welcome Guest | Login

rendering a file

Hi all
this is from my "read" controller
def story
  @story = Story.find(params[:id])
  @path = "http://bluemag.com/files/" + @story.filename
  render :action => "story", :layout => false
end
and then this is from views/read/story.rhtml
<%= render :file => @path, :layout => false %>
I get nada. Any ideas? I'm running rails 1.1.2

2006-08-28 03:39 PM

First of all, you should update to 1.1.6 - very important security fix.

Second, I don't believe you need this line in your controller:
render :action => "story", :layout => false
Are you seeing any errors in your logs?  

2006-08-29 03:18 AM

Thanks Brian! I took care of the Rails version and took that line out of my controller. Still nothing. I get the "Rails application failed to start properly" error. The log entries look normal up until the point where they should say "Completed":

Processing ReadController#story (for 65.213.63.17 at 2006-08-29 12:32:27) [GET]
 Session ID: 5e46a6daed83d62a171e2dcd37d43be4
 Parameters: {"action"=>"story", "id"=>"155", "controller"=>"read"}
Rendering  within layouts/read
Rendering read/story
Any ideas?

2006-08-29 12:40 PM

Hmmm - Can you get everything out of your index.rhtml file (put a hello world in there or something)?    

Also, looking at the Rails API for render:
  # Renders the template located at the absolute
 # filesystem path
 render :file => "/path/to/some/template.rhtml"
 render :file => "c:/path/to/some/template.rhtml"
....should you have the "http://bluemag.com/files/" in the path?  Looks like you don't need it.  

2006-08-29 12:50 PM

Okay I'm on the right track... i realized i don't want a views/read/story.rhtml file, i just want to render within the "story" action. So I've got it almost working, http://bluemag.com/read/story/152 displays the filename that should be visible at that url but I can't get it to actually render the file. Thanks!

2006-08-29 01:23 PM

Sounds like you'll get it.  Let me know if you need any more specific help.

2006-08-29 01:49 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!