title: Rails responders and Layouts
body: <p>Ok, so I have a Rails app, the 'responders' gem and Ember.js.</p>
  
  <p>I have set up the ember.js, I have created a model  to test my app ( Lead ) and the controller/layout/view that it needs. I use Rails 4.2, ruby 2.2 and MySQL.</p>
  
  <p>So here is the controller I wrote in order to work with ember (api-style)</p>
  
  <pre><code>class Api::V1::LeadsController &lt; ApplicationController
    respond_to :json
  
    def index
      respond_with Lead.all, layout: "application"
    end
  
    def show
      respond_with lead
    end
  
    def create
     respond_with :api, :v1, Lead.create( lead_params )
    end
  
    def update
      respond_with lead.update( lead_params )
    end
  
    def destroy
     respond_with lead.update( lead_params )
    end
  
  private
  
    def lead
      Lead.find( params[:id] )
    end
  
    def lead_params
      params.require( :lead ).permit( :first_name, :last_name, :email, :phone, :status, :notes )
    end
  
  end
  </code></pre>
  
  <p>I haven't changed the application_controller. I have the default layout (application.html.haml) and all the routing works fine. If I do not use the "respond_to :json" and the responders gem, everything works fine. As it is now, the layout is not rendered. I have to change it to "application.json.haml", but this is no good as I need the the markup of the layout and I want to yield inside it the "json" of my data.</p>
  
  <p>Any ideas? So far I have not found a solution.</p>