Noob question; remote_form_for

My problem is when submitting a form with remote_form_for I got a
message that says:"Template is missing

Missing template messages/create.html.erb" so the remote_form_for
searches for a template of the create method instead of just updates
the required div, here is the code:

Here is the link when I call the form:

<%= link_to_remote "Send new SMS", :url => 'messages/new_sms',
                  :loading => "'loading')", :update =>
                  :complete => "Element.hide('loading')"%></p>


<% remote_form_for :message, @message, :url => 'messages/create',
                    :loading => "'sending')", :update =>
                    :complete => "Element.hide('loading')" do |f| %>

#messaging_area is the div that lists sent messages, this div should
be updated by Ajax to show the newly-sent message

<table id="new_message_form">
  <td colspan="2"><p class="labelcell">Message</p> </td>
  <td colspan="2"><%= f.text_area :text, :id => 'text', :size =>
'30x10', :class => 'fieldcell' %></td>

  <td colspan="2"><p class="labelcell">Sender</p> </td>
  <td colspan="2"> <%= f.text_field :sender, :class => 'fieldcell' %></

  <td colspan="2"><p class="labelcell">Number</p> </td>
  <td colspan="2"><%= f.text_field :number, :class => 'fieldcell' %></


<tr><td><%= f.submit "Send", :class => 'sbutton' %></td></tr>




  def create
    @user = User.find(logged_in_user)
    @message = => params[:message][:text],
      :sender => params[:message][:sender],
      :number => params[:message][:number],
      :user_id =>

    respond_to do |format|
      @numbers_array = params[:message][:number].split(/\,+\s*|\s+/)
      # @numbers_from_file = params[:contact][:file].split(/\n/)

      if @numbers_array.size <= 16
        @new_count = @user.messages_count + @numbers_array.size
# flash[:notice] = 'Message was successfully created.'
# format.xml { render :xml => @message, :status
=> :created, :location => @message }

        @numbers_array.size > 16
        format.html {render :action => "new"}
        flash[:notice] = 'More than ur allowed max'
        format.html { render :action => "new" }
        format.xml { render :xml => @message.errors, :status
=> :unprocessable_entity }




I hope everything is clear, I know this is a silly problem but I've
read the documentation available about remote_form_for and did a lot
of googling but didn't know what causes the action to look for a
create.html.erb page !!!

Your help is highly appreciated.


Your remote_form_for is not requesting the xml format and therefore
its never getting to the 'render :xml' call in your controller. It's
trying to do the default render which is to render the erb template
which of course doesn't exist.

I think you need your :url option to be :url => 'messages/create.xml'

remote_form_for :message, @message,
  :url => 'messages/create.xml',
  :loading => "'sending')",
  :update => 'messaging_area',
  :complete => "Element.hide('loading')" do |f|

I don’t think this is related to xml at all, why would I need to render xml?

Any help?

The problem has been solved I simply added {redirect_to messages_path} for the format.html, but now I have another problem, when submitting the form, the layout is rendered again though I turned all layouts off for Ajax requests !!!