title: Getting Action controller UNKNOWN FORMAT error- for rails 4 + AJAX call
body: <p>I am trying to do a remote search in a ajax form, where the user types into a code, and submits via ajax, the controller gets the code and see if anything in the database matches, then controller then returns a response appropriately. I keep getting an UNKNOW <code>ActionController::UnknownFormat</code> when I try to search. </p>
  
  <p>Here is my controller action</p>
  
  <pre><code>class TenantsController &lt; ApplicationController
  
  
  def search
  @count = 0
  @property = Property.find_by_propertyid(params[:propertyid])
  @current_tenant =current_tenant
  if @property
    toast('success', "#{@property.propertyid}")
    @current_tenant.landlord_id = @property.landlord_id
    @current_tenant.property_id = @property.id
    @current_tenant.save
  
  
  
    redirect_to authenticated_tenant_path
  else
    respond_to do |format|
      format.js
    end
  
    redirect_to authenticated_tenant_path
  
  end
  </code></pre>
  
  <p>end</p>
  
  <p>here is my view template form</p>
  
  <pre><code>           &lt;%= form_tag({controller: "tenants", action: "search", remote:true,}, method: "get") do %&gt;
                    &lt;%= label_tag(:propertyid, "Search for:") %&gt;
                    &lt;%= text_field_tag(:propertyid) %&gt;
                    &lt;%= submit_tag("Search") %&gt;
             &lt;% end %&gt;
  </code></pre>
  
  <p>here is the route file</p>
  
  <pre><code>  match '/tenant/search' =&gt; "tenants#search",via: [:get, :post]
  </code></pre>
  
  <p>I have a search.js.erb with a simple <code>alert('i am here')</code></p>
  
  <p>here is the error log</p>
  
  <pre><code>Started GET "/tenants/edit" for 127.0.0.1 at 2015-03-29 21:54:33 -0400
  Processing by Tenant::RegistrationsController#edit as JS
    Tenant Load (0.8ms)  SELECT "tenants".* FROM "tenants" WHERE "tenants"."id" = 27 ORDER BY "tenants"."id" ASC LIMIT 1
    Tprofile Load (0.2ms)  SELECT "tprofiles".* FROM "tprofiles" WHERE "tprofiles"."tenant_id" = 27 LIMIT 1
    Rendered tenantprofiles/_edit.html.erb (3.7ms)
    Rendered tenants/registrations/edit.html.erb within layouts/dash_tenants (30.2ms)
    Rendered layouts/tenants/_dash_side.html.erb (0.7ms)
    Rendered layouts/tenants/_dash_header.html.erb (0.5ms)
  Completed 200 OK in 88ms (Views: 77.5ms | ActiveRecord: 0.9ms)
  
  
  Started GET "/tenant/search?utf8=%E2%9C%93&amp;propertyid=a&amp;commit=Search" for 127.0.0.1 at 2015-03-29 21:54:35 -0400
  Processing by TenantsController#search as HTML
    Parameters: {"utf8"=&gt;"✓", "propertyid"=&gt;"a", "commit"=&gt;"Search"}
    Tenant Load (0.2ms)  SELECT "tenants".* FROM "tenants" WHERE "tenants"."id" = 27 ORDER BY "tenants"."id" ASC LIMIT 1
    Property Load (0.4ms)  SELECT "properties".* FROM "properties" WHERE "properties"."propertyid" = 'a' LIMIT 1
  Completed 406 Not Acceptable in 7ms
  
  ActionController::UnknownFormat - ActionController::UnknownFormat:
    actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:372:in `retrieve_collector_from_mimes'
    actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:189:in `respond_to'
    app/controllers/tenants_controller.rb:38:in `search'
  </code></pre>
  
  <p>but I dont even get there. What am i doing wrong?</p>