Topic: Render :template => Bullcrap!

I swear I must have some sort of mental block when it comes to the render statement.  But doing my best to ignore my pride and be productive I'll allow you to glimpse my greatest brain failures and ask for your patience and help.  I've bought the RJS manual and it has a table that lists the arguments that you can pass to render in a replace_html statement and the like.  Included in that list is :template, and :action.  However a statement such as this:

page.replace_html "main", :template => "projects/show"

Does not work.  I get a ajax error in return saying

RJS Error
Type Error: html has no properties

Element.update("main",null)

If I pass render a string such as "this is urking me mightily" then it will work fine.  I've also done this several times before using partials, but I don't want to throw something like an actions default rhtml template into a partial.

Last edited by circuitshaman (2006-08-21 16:32:33)

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Render :template => Bullcrap!

I'm not familiar with the render_html command. Have you tried this?

page.replace_html 'main', render(:template => 'projects/show')

Railscasts - Free Ruby on Rails Screencasts

Re: Render :template => Bullcrap!

I aplogize, typo in my post.  It's page.replace_html  I edit that.

As I was scrounging up the docs for that statement I found that it only mentions strings and "partial templates" as an option for render.  So I guess my question becomes do you know of any ajax method that will replace the html inside a tag with a template (without the layout)?  I'm doing it already with link_to_remote and the :update statement, but as I make multiple ajax calls in this case I need it to be in RJS.

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Render :template => Bullcrap!

Does the code example I gave not work?

Railscasts - Free Ruby on Rails Screencasts

Re: Render :template => Bullcrap!

Sorry it took me so long to get back to you.  No it didn't.  It doesn't error out, but it renders nothing.  It might be passing a true to render, but no text makes it through.

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Render :template => Bullcrap!

I know you mentioned it, but did you try using :action instead of :template?

[code lang="ruby"]page.replace_html "main", :action => "projects/show"[/code]

Re: Render :template => Bullcrap!

I have, I get the same RJS error as in the first post with :template

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)