Rendering action into div

Get your action to:
render :text => ‘Hello world’

In your page:
link_to_remote(‘Some Text’, :update => “my_div_id”, :url => {:action => “my_action”})

Make sure your page has a

Which one is better making an RJS or using

def edit
  widget = Widget.find_by_id(params[:id])
  render :update do |page|
    page.replace_html "widget_#{widget.id}", :partial => 'widget',
:object => widget
  end
end

I always prefer RJS , because it makes debugging easier and my
controller a bit less clustered.
Check the API about RJS you will get many examples and all other help
needed.

Web Blogger wrote:

Which one is better making an RJS or using

def edit
  widget = Widget.find_by_id(params[:id])
  render :update do |page|
    page.replace_html "widget_#{widget.id}", :partial => 'widget',
:object => widget
  end
end

As I understand it, this *is* RJS, just not using an RJS template, such
as

edit.js.erb

I always prefer RJS , because it makes debugging easier

That, I believe, is a personal opinion. 90-some-odd percent of my
debugging happens in controllers, and I like to have related code handy.
I often make some decisions inside the render :update block, and it's
easier _for me_ to have it in the controller.

and my
controller a bit less clustered.

It depends on a lot of things. I often grow weary of bouncing around
from file to file, as I tend to use a lot of view partials. When I have
one or two lines of code to respond to an ajax call, it doesn't bother
me to have it in the controller.

I know there are _best practices_, but at the end of the day, I have to
get work done and be happy doing it. No two programmers are exactly
alike, and one of the things I like about Rails is that it allows a
certain something-or-other to be done in a variety of ways, but still
with programmer happiness in mind.

Peace,
Phillip