I have a rails 3.1 application with Ruby 1.8.7. I try to create contacts through ajax, but keep getting the missing template error.
ActionView::MissingTemplate (Missing template contacts/create, application/create with {:handlers=>[:coffee, :builder, :erb], :locale=>[:en, :en], :formats=>[:html]}. Searched in: * "/Users/Me/Sites/t3/app/views" ):
The form:
<%= form_for @contact, :remote => true do |f| %> <%= f.hidden_field :customer_id, :value => @customer.id %> <table> <tr> <td class="pten"> <%= f.text_field :first_name, :style => "width:120px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.text_field :last_name, :style => "width:120px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.text_field :position, :style => "width:120px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.text_field :phone, :style => "width:120px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.text_field :ext, :style => "width:60px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.text_field :email, :style => "width:200px;", :class => "contact_input" %> </td> <td class="pten"> <%= f.submit 'Create', :class => "submit" %> </td> </tr> </table> <% end %>
Controller:
def create @contact = Contact.new(params[:contact]) @customer = @contact.customer @contact.save respond_to do |format| format.js end end
Create.js.erb:
$(".contact_list").append("<%= escape_javascript(render @contact)%>"); $('.contact_input:input').val('');
Development.rb:
Myapp::Application.configure do
source share