title: Rails form on ajax submission throws a 406 not acceptable error
body: <p>I'm new to rails so I'm probably messing this up somehow (obviously). I have a form that is sending the submission back to the controller via ajax. </p>
  
  <p>This is that file
  /<em>index.html.erb</em>/</p>
  
  <pre><code>&lt;% provide(:title,'PlanYourTask') %&gt;
  &lt;div class="mycontainer"&gt;
  &lt;div class="myprojcont container"&gt;
      &lt;div class="row yourprojects" id="yourproject_&lt;%=current_user.id%&gt;"&gt;
          &lt;% if @projects.any? %&gt;
                  &lt;%@projects.each do |project| %&gt;
                      &lt;%=render 'projects/projects',:project =&gt; project %&gt;
                  &lt;%end%&gt;
          &lt;%end%&gt;
              &lt;div class="col-md-3 col-xs-12 newproject"&gt;
                      &lt;a class="btn btn-warning" style="border-bottom-left-radius:0px;border-bottom-right-radius:0px;display:block;"&gt;Create New Project
                      &lt;/a&gt;
  
                  &lt;div class="dropdownnewproject"&gt;
                      &lt;div class="projectdropdown" style="background:#bbb;border-bottom-left-radius:5px;border-bottom-right-radius:5px;margin:auto;padding:2px;
                      display:block;"&gt;
                      &lt;p class="example-description"&gt;Enter the name of the project&lt;/p&gt;
                      &lt;%=form_for Project.new,:remote =&gt; true do |f|%&gt;
                          &lt;%=f.text_field :name,class:'form-control'%&gt;
                          &lt;%=f.submit class:'col-md-6 btn btn-success'%&gt;
                      &lt;%end%&gt;
                      &lt;a href="#" class="closeproject"&gt;&lt;i class="fa fa-times fa-lg" style="margin:10px auto;"&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
                  &lt;script type="text/javascript"&gt;
                      $('.newproject &gt; a').click(function(e){
                          $('.dropdownnewproject').slideDown(1000);
  
                          e.preventDefault();
                      });
                      $('.closeproject').click(function(e){
                          $('.dropdownnewproject').slideUp(1000);
                          e.preventDefault();
                      });
                  &lt;/script&gt;
  
  
  
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If you can see there is a form inside it which send an ajax request for a new project creation.</p>
  
  <p>The project controller is here</p>
  
  <pre><code>class ProjectsController &lt; ApplicationController
      before_filter :require_user
      def new
          @projects=current_user.projects
          @project=current_user.projects.new
      end
  
      def create
          @project=current_user.projects.create(params[:project])
  
  
          respond_to do |format|
          if @project.save
              format.html{redirect_to :projects}
              format.js
  
              flash[:success]="Project created successfully"
          else
              render new
          end
      end
  
      end
  
      def show
          @project=Project.find(params[:id])
  
      end
  
      def index
          @projects=current_user.projects
      end
  
  
  
  
  end
  </code></pre>
  
  <p>Finally here is my create.js.erb file</p>
  
  <pre><code>$('#yourprojects_&lt;%=current_user.id%&gt;').append('&lt;%=j render partial:"projects/projects", object: @project %&gt;');
  </code></pre>
  
  <p>/<em>projects/projects.html.erb</em>/</p>
  
  <pre><code>&lt;div class="col-md-3 projects" style="margin-bottom:15px;"&gt;
  &lt;p style="font-family:TimesNewRoman;font-size:25px;margin:25px auto;text-align:center;"&gt;&lt;%=link_to project.name,project,style:'text-decoration:none;'%&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>/<em>Project.rb file</em>/</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
      extend FriendlyId
  
      friendly_id :name, use: :slugged
      validates :name,presence: :true
      validates :description,presence: :true
      has_many :tasks,dependent: :destroy
      has_many :assigns,dependent: :destroy
      has_many :subtasks,through: :tasks
      has_many :users,through: :assigns
  
  
      after_create :add_tasks
  
      private
  
      def add_tasks
          self.tasks.build(taskname: "Production")
          self.tasks.build(taskname: "Development")
          self.tasks.build(taskname: "Test")
      end 
  
  end
  </code></pre>
  
  <p>On clicking the submit button when i check my network tab in chrome,it send a  post request to /projects but the error is 406 not acceptable.</p>
  
  <p>Can someone please help me with this.</p>