Ajax problem migrating to Rails 2.0

Hi, I was developping an application and everything was working
properely, until I decided to migrate to RoR 2.0. I was using
Scriptaculous to add new itens to a list using Highlight visual
effect. But in RoR 2.0 when I press submit button in the form, only
the partial is rendered to the browser, not the entire page, with the
new item added with highlight effect. What should I do to correct

Here the code:

The partial: _area.html.erb
<li id="area_<%= area.id %>">
  <div class="nome_item">
    <%= area.nome -%>
  <%= link_to "Editar", :action => "editar", :id => area.id %>
  <%= link_to_remote "[x]", :url=> {:action => "excluir", :id =>
area.id} %>

The list in the mais view page: lista.html.erb
<!-- Lista areas existentes -->
  <ul id="item_lista">
    <%= render :partial => 'area/area', :collection => @areas %>

The criar.js.rjs:
if @area.new_record?
  page.alert @area.errors.full_messages.join("\n")
  page.insert_html :top, 'item_lista', :partial => 'area'
  page.visual_effect :highlight, "area_#{@area.id}"
  page.form.reset 'area_form'

The controller: area_controller.rb
  def lista
    @areas = Area.find(:all, :conditions => ["conta_id = ?",
session[:usuario].conta], :order => "id DESC")

  def criar
    @area = Area.new(params[:area])
    @area.conta = session[:usuario].conta
    if @area.save
      return if request.xhr?
      render :partial => 'area', :object => @area
      flash.now[:notice] = "N&atilde;o deu certo. Tente novamente."
      render :controller => 'area', :action => 'lista'

Thanks a lot.

Hi, how did you migrate from Rails version X to Rails 2.0.2? For example, did you switch the Rails version information in the environment.rb? If this is the case, you’ll also need to update the configuration file by doing the following in the root of your rails application:

rake rails:update

Otherwise, please provide more detail as to what steps you performed to do the migration from Rails X to Rails 2.0.2.


Hi, I've unistalled Ruby, and reinstall everything from scracht. Ruby
and gems.
I created a new applicatinon, with the same name, and copied pages
from models, controllers and views. (as well as plugins)
After that, I modified every piece of code that was deprecated.
Everything is working perfect, except Ajax effects.
Thanks a lot.

I realized I've migrated my forms to form_for, not for
remote_form_for. :-S
Now is everything fine.