trouble with remote_form_for & html_update

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

This is the html:

<div id='aremark'>
<%= render :partial => 'comment' %>
</div>

  <% remote_form_for :comment, :url=>story_comments_path(@story), :html
=> { :id => 'comment' } do |form| %>
       <h5><label for="login">Make a comment:</label></h5>
       <div id="body"><%= form.text_field :body %></div>
       <p><%= submit_tag 'Comment' %></p>

  <% 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

<script>
aremark = page.getElementById("aremark")
page.replace_html('aremark', :partial => "content")
</script>

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

Neil Bye 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.

This is create.rjs

<script>
aremark = page.getElementById("aremark")
page.replace_html('aremark', :partial => "content")
</script>

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

Fred

So I strip it down to

page.replace_html('aremark', :partial => "content")

Still won't work without refreshing the page

Frederick Cheung wrote:

In the log I get

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

Does that help anyone to explain

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

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?

Neil Bye 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???