# Replace\_html in 2.2.2

**URL:** <https://www.ruby-forum.com/t/replace-html-in-2-2-2/160466>\
**Category:** Rails\
**Created:** [February 16, 2009, 6:15pm UTC](https://www.ruby-forum.com/t/replace-html-in-2-2-2/160466 "2009-02-16T18:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@eyp](https://www.ruby-forum.com/u/eyp)\
**Post date:** [February 16, 2009, 6:15pm UTC](https://www.ruby-forum.com/t/replace-html-in-2-2-2/160466/1 "2009-02-16T18:15:42Z")

</div>

Hello, I’m in troubles with an easy thing I’ve done several times, but  
I don’t see what I’m doign wrong.

Having index.html.erb:

# Projects

\<% for project in @projects %\>

\<% end %\>

|
| |
| \<%= project.name %\> | \<%= project.description %\> | \<%= link\_to 'Show', project %\> | \<%= link\_to 'Edit', edit\_project\_path(project) %\> | \<%= link\_to 'Destroy', project, :confirm =\> 'Are you sure?', :method =\> :delete %\> |

  

\<%= link\_to\_remote ‘New project’, :url =\> new\_project\_path %\>

new.rjs:

page.replace\_html “new\_project”, :partial =\> “new”, :object =\>  
@project

and finally \_new.html.erb:

SOME TEXT

When I’m within index.html.erb and click on ‘New project’ link, I see  
this log in the console:

Processing ProjectsController#new (for 127.0.0.1 at 2009-02-16  
18:08:12) [GET]  
Parameters:  
{“authenticity\_token”=\>“1efcdedfb3b680581058efa75cdbc143bf880b65”}  
SQL (0.1ms) SET NAMES ‘utf8’  
SQL (0.0ms) SET SQL\_AUTO\_IS\_NULL=0  
Project Columns (0.7ms) SHOW FIELDS FROM `projects`  
Rendering projects/new  
Rendered projects/\_new (0.2ms)  
Completed in 11ms (View: 2, DB: 1) | 200 OK [[http://localhost/projects/](http://localhost/projects/)  
new?authenticity\_token=1efcdedfb3b680581058efa75cdbc143bf880b65]

but nothing happens, thus is, it doesn’t replace the ‘new\_project’  
DIV. What I’m doing wrong, because I can’t see it.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![eyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@eyp](https://www.ruby-forum.com/u/eyp)\
**Post date:** [February 17, 2009, 10:47am UTC](https://www.ruby-forum.com/t/replace-html-in-2-2-2/160466/2 "2009-02-17T10:47:37Z")

</div>

I can answer myself. I didn’t notice that in Rails 2.2 I need to make  
changes in the controller’s action to respond to JS.

def new  
@project = Project.new  
@states = ProjectStatus.all.collect {|s| [s.name, s.name]}  
respond\_to do |format|  
format.html # new.html.erb  
format.js # new.js.rjs \<--------------------------------- HERE!  
end  
end

This is a thing I don’t like with new releases of Rails, they always  
broke backwards compatibility…

---

<div class="post-metadata">

**Author:** ![eyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@eyp](https://www.ruby-forum.com/u/eyp)\
**Post date:** [February 17, 2009, 11:01am UTC](https://www.ruby-forum.com/t/replace-html-in-2-2-2/160466/3 "2009-02-17T11:01:09Z")

</div>

On Tue, Feb 17, 2009 at 1:46 AM, Eduardo YÃ¡Ã±ez Parareda \<  
removed\_email\_address@domain.invalid\> wrote:

> end  
> end
> 
> This is a thing I don’t like with new releases of Rails, they always  
> broke backwards compatibility…

Hi, you should never upgrade without reading the release notes and how  
it  
may effect your current application.

Good luck,

-Conrad
