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:

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

On Jul 27, 8:56 pm, Neil B. [email protected] 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

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. [email protected] 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

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.

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

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

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?