# Trouble with remote\_form\_for & html\_update

**URL:** <https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293>\
**Category:** Rails\
**Created:** [July 27, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293 "2010-07-27T21:56:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 27, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/1 "2010-07-27T21:56:27Z")

</div>

I have a form that accepts comments and adds them to a list without  
refreshing the page.

This is the html:

\<%= render :partial =\> 'comment' %\>

\<% remote\_form\_for :comment, :url=\>story\_comments\_path(@story), :html  
=\> { :id =\> ‘comment’ } do |form| %\>

##### Make a comment:
  

\<%= form.text\_field :body %\>
  

\<%= submit\_tag ‘Comment’ %\>

\<% end %\>

The form works i.e on refreshing the page the new comment is seen in the  
comment partial.

From comments\_controller

def create  
@story = Story.find(params[:story\_id])  
@story.comments.create params[:comment]  
flash[:notice] = “Thank you for commenting”  
end

This is create.rjs

This was working then didn’t. I don’t know what I did to break it.  
Can anybody see where I am going wrong?

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 27, 2010, 11:15pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/2 "2010-07-27T23:15:40Z")

</div>

On Jul 27, 8:56 pm, Neil B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This is create.rjs

This is weird - if it’s an rjs file you don’t want script tags - an  
rjs file only contains ruby.

Fred

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 28, 2010, 12:35am UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/3 "2010-07-28T00:35:35Z")

</div>

So I strip it down to

page.replace\_html(‘aremark’, :partial =\> “content”)

Still won’t work without refreshing the page

Frederick C. wrote:

> On Jul 27, 8:56ï¿½pm, Neil B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > This is create.rjs
> 
> This is weird - if it’s an rjs file you don’t want script tags - an  
> rjs file only contains ruby.
> 
> Fred

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 27, 2010, 10:02pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/4 "2010-07-27T22:02:48Z")

</div>

Neil B. wrote:

> I have a form that accepts comments and adds them to a list without  
> refreshing the page.

It should read

I want a form that accepts comments and adds them to a list without  
refreshing the page.

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 28, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/5 "2010-07-28T14:44:29Z")

</div>

In the log I get

ActionView::MissingTemplate (Missing template comments/create.erb in  
view path app/views):

Does that help anyone to explain

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 28, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/6 "2010-07-28T16:58:11Z")

</div>

Hello,  
Shouldn’t you be doing page.replace\_html from inside your controller  
and using your rjs page as a paramater passed to page.replace\_html??

I think the log is telling you that your request found def  
create…but without making def create render something other than  
create.html.erb, won’t the controller be looking for that instead of  
your rjs template?

Oldroy

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 28, 2010, 7:02pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/7 "2010-07-28T19:02:30Z")

</div>

Neil B. wrote:

> Oldroy wrote:  
> but without making def create render something other than  
> create.html.erb, won’t the controller be looking for that instead of  
> your rjs template?

I think this is the problem but I don’t know the solution. Surely in the  
absence of create.html.erb it should find create.rjs but  
doesn’t???

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [July 28, 2010, 6:43pm UTC](https://www.ruby-forum.com/t/trouble-with-remote-form-for-html-update/192293/8 "2010-07-28T18:43:19Z")

</div>

Oldroy wrote:

> Hello,  
> Shouldn’t you be doing page.replace\_html from inside your controller  
> and using your rjs page as a paramater passed to page.replace\_html??

I don’t understand, how would it find the rjs and if the  
page.replace\_htm is in the controller what would it contain?
