Trouble with render :partial from controller

Hi,
I’m definitely a newbie on rails here. My very first attempt has gone
well up until this point, but for some reason, when I try to do a render
partial, I’m getting a full screen refresh.

I did a render partial just fine from an rhtml file. This problem is
specifically when calling render :partial => “my_partial” from the
controller’s .rb code. It’s just really one line that is not doing what
it’s supposed to…

render :partial => "my_partial_file"

It is indeed finding the file (_my_partial_file.rhtml) and rendering it,
but it is not doing it as a partial. It is refreshing the screen and
rendering this partial file without any of the original page goodies.

thanks,
jp

P.S.
A friend of mine is trying to get me to use the scriptaculous
visual_effect stuff to do this, and I probably will, but first I would
like to understand what’s going on with a simple render :partial.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Jeff P. wrote:

Hi,
I’m definitely a newbie on rails here. My very first attempt has gone
well up until this point, but for some reason, when I try to do a render
partial, I’m getting a full screen refresh.

I did a render partial just fine from an rhtml file. This problem is
specifically when calling render :partial => “my_partial” from the
controller’s .rb code. It’s just really one line that is not doing what
it’s supposed to…

render :partial => "my_partial_file"

If you render a partial directly from an action, and that action has
not been called via Ajax, the partial is all you’ll get.

If you’re trying to update just a portion of the screen, that action
would need to be called via ajax, and told which div to replace/update
etc.

Are you invoking the action via Ajax (link_to_remote, etc)

Alan

Alan F. wrote:

If you render a partial directly from an action, and that action has
not been called via Ajax, the partial is all you’ll get.

If you’re trying to update just a portion of the screen, that action
would need to be called via ajax, and told which div to replace/update
etc.

Are you invoking the action via Ajax (link_to_remote, etc)

Alan

Alan, thanks, that did the trick!

jp

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