# Ajax problem migrating to Rails 2.0

**URL:** <https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775>\
**Category:** Rails\
**Created:** [May 16, 2008, 8:53am UTC](https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775 "2008-05-16T08:53:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franklin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3e96dc/32.png) [@Franklin](https://www.ruby-forum.com/u/Franklin)\
**Post date:** [May 16, 2008, 8:53am UTC](https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775/1 "2008-05-16T08:53:55Z")

</div>

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  
this?

Here the code:

The partial: \_area.html.erb

- 
 \<%= 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  
…

 \<%= render :partial =\> 'area/area', :collection =\> @areas %\> 
...

The criar.js.rjs:  
if @area.new\_record?  
page.alert @area.errors.full\_messages.join("\n")  
else  
page.insert\_html :top, ‘item\_lista’, :partial =\> ‘area’  
page.visual\_effect :highlight, “area\_#{@area.id}”  
page.form.reset ‘area\_form’  
end

The controller: area\_controller.rb  
…  
def lista  
@areas = Area.find(:all, :conditions =\> [“conta\_id = ?”,  
session[:usuario].conta], :order =\> “id DESC”)  
end

def criar  
@area = Area.new(params[:area])  
@area.conta = session[:usuario].conta  
if @area.save  
return if request.xhr?  
render :partial =\> ‘area’, :object =\> @area  
else  
flash.now[:notice] = “Não deu certo. Tente novamente.”  
render :controller =\> ‘area’, :action =\> ‘lista’  
end  
end  
…

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Franklin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3e96dc/32.png) [@Franklin](https://www.ruby-forum.com/u/Franklin)\
**Post date:** [May 18, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775/2 "2008-05-18T16:21:53Z")

</div>

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.

-Conrad

---

<div class="post-metadata">

**Author:** ![Franklin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3e96dc/32.png) [@Franklin](https://www.ruby-forum.com/u/Franklin)\
**Post date:** [May 19, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775/3 "2008-05-19T15:28:10Z")

</div>

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.  
Franklin.

---

<div class="post-metadata">

**Author:** ![Franklin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3e96dc/32.png) [@Franklin](https://www.ruby-forum.com/u/Franklin)\
**Post date:** [May 25, 2008, 4:01pm UTC](https://www.ruby-forum.com/t/ajax-problem-migrating-to-rails-2-0/137775/4 "2008-05-25T16:01:54Z")

</div>

I realized I’ve migrated my forms to form\_for, not for  
remote\_form\_for. :-S  
Now is everything fine.  
Thanks.
