title: ActionController::UnknownFormat with format.js for ajax implementation (Rail 4)
body: <p>i try to use Ajax in my application with Rails 4. To send my js to the client i use : </p>
  
  <pre><code>   respond_to do |format|
          format.js 
     end
  </code></pre>
  
  <p>in my controller. 
  But it's generated error  "ActionController::UnknownFormat" i my controller.
  Someone can help me please ? </p>
  
  <p>main_controller.rb: </p>
  
  <pre><code>class Oweb::MainController &lt; ApplicationController
      def index
          .....
      end
      def setmagasinstatus
        begin                     
         @mag = Magasin.find(params[:id]) 
         if @mag.etatmagasin.lib == 'Ouvert'
              @mag.etatmagasin = Etatmagasin.where(lib: 'Fermé').first
         else
              @mag.etatmagasin = Etatmagasin.where(lib: 'Ouvert').first
         end 
        rescue ActiveRecord::RecordNotFound
         logger.error("Attempt to access invalid Magasin #{params[:id]}")
         redirect_to_index("Invalid Magasin")
        else
         @mag.save
         @mags = Magasin.where(user_id: current_user.id) 
  
         respond_to do |format|
              format.js 
         end
  
       end
      end
  end
  </code></pre>
  
  <p>setmagasinstatus.js.erb : </p>
  
  <pre><code>page.replace_html("bloc_magasin", :partial =&gt; "listmagasins", :object =&gt; @mags)
  </code></pre>
  
  <p>layouts/application.html.slim:</p>
  
  <pre><code>doctype html
  html
      head
          meta charset="utf-8"
          meta http-equiv="X-UA-Compatible" content="IE=edge"
          meta name="viewport" content="width=device-width, initial-scale=1.0"
          meta name="description" content=""
          meta name="author" content=""
  
          title = yield(:title)
  
          = stylesheet_link_tag "application"
          = csrf_meta_tags
  
      body
       .........
                  = yield
  
          = javascript_include_tag "application"
          = yield :scripts
  </code></pre>
  
  <p>gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.1.1'
  
  group :development do
    gem 'mysql2'
  end
  group :production do
    gem 'pg'
  end
  
  gem 'sass-rails', '~&gt; 4.0.3'
  
  gem 'uglifier', '&gt;= 1.3.0'
  
  gem 'coffee-rails', '~&gt; 4.0.0'
  
  gem 'therubyracer',  platforms: :ruby
  
  
  gem 'jquery-rails'
  
  gem 'turbolinks'
  
  gem 'jbuilder', '~&gt; 2.0'
  
  gem 'sdoc', '~&gt; 0.4.0',          group: :doc
  
  gem 'spring',        group: :development
  
  gem 'devise', '~&gt; 3.2.4'
  
  gem 'slim-rails', '~&gt; 2.1.4'
  
  gem 'bootstrap-sass', '~&gt; 3.1.1.1'
  
  gem 'compass-rails', '~&gt; 1.1.7'
  
  gem 'simple_form', '~&gt; 3.0.2'
  gem 'activeadmin', github: 'gregbell/active_admin'
  
  gem 'polyamorous', github: 'activerecord-hackery/polyamorous'
  
  gem 'ransack', github: 'activerecord-hackery/ransack'
  
  gem 'formtastic', github: 'justinfrench/formtastic'
  
   gem 'debugger', group: [:development, :test, :production]
  
  gem 'geocoder'
  gem 'gmaps4rails', '~&gt; 2.1.2'
  </code></pre>
  
  <p>logs:</p>
  
  <pre><code>Started GET "/oweb/main/setmagasinstatus?id=3" for 192.168.56.1 at 2014-08-01 06:22:06 +0000
  Processing by Oweb::MainController#setmagasinstatus as HTML
    Parameters: {"id"=&gt;"3"}
  Completed 406 Not Acceptable in 103ms
  
  ActionController::UnknownFormat (ActionController::UnknownFormat):
    app/controllers/oweb/main_controller.rb:24:in `setmagasinstatus'
  
  
    Rendered /home/vagrant/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (2.1ms)
    Rendered /home/vagrant/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.2ms)
    Rendered /home/vagrant/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.1ms)
    Rendered /home/vagrant/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (27.1ms)
  </code></pre>