title: Rails 4: Stop redirect after create or update form
body: <p>How can I <strong>not redirect</strong> to an other view after creating or updating a form using <code>remote: true</code> in Rails?</p>
  
  
  
  <pre><code>//route
  resources :pictures
  
  
  // action
  def create
    @picture = Picture.new(picture_params)
  
    respond_to do |format|
      if @picture.save
        #format.html { redirect_to @picture, notice: 'Picture was successfully created.' }
        #format.json { render :show, status: :created, location: @picture }
        format.js
      else
        format.html { render :new }
        #format.json { render json: @picture.errors, status: :unprocessable_entity }
      end
    end
  end
  
  
  // view
  &lt;%= form_for(@picture, remote: true, :authenticity_token =&gt; true, html: { multipart: true } ) do |f| %&gt;
  
      [...]
  
  &lt;%= f.submit %&gt;
  </code></pre>
  
  <p>If I just remove the redirect function I get the error:</p>
  
  <pre><code>ActionController::UnknownFormat 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BlQDz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BlQDz.png" alt="error image"></a></p>