title: Trying to edit JSON response to return authentication token when using devise on rails app
body: <p>I've got a rails application which uses Devise for authentication and works fine in the browser.  I want to configure it so that it will interact with an Android application I'm building.  I'm trying to override the standard JSON response so that it returns the authentication token which I need to login.</p>
  
  <p>This problem seems to be answered in this question and I'm trying to adapt it.
  <a href="https://stackoverflow.com/questions/4627703/using-devise-tokens-to-log-in-is-this-built-in">Using Devise tokens to log in, is this built in?</a></p>
  
  <p>I have specified the following config/initializers/devise.rb:</p>
  
  <pre><code>config.token_authentication_key = :auth_token
  </code></pre>
  
  <p>I've changed my routes file so that it looks like this:
      devise_for :managers, :controllers => { :sessions => "Managers/sessions" }</p>
  
  <p>And then I've created a file sessions_controller.rb with the following:</p>
  
  <pre><code>class Managers::SessionsController &lt; Devise::SessionsController
   def create
     resource = warden.authenticate!(:scope =&gt; resource_name, :recall =&gt; "#{controller_path}#new")
     set_flash_message(:notice, :signed_in) if is_navigational_format?
     sign_in(resource_name, resource)
  
  respond_to do |format|
    format.html do
      respond_with resource, :location =&gt; redirect_location(resource_name, resource)
    end
    format.json do
      render :json =&gt; { :response =&gt; 'ok', :auth_token =&gt; current_user.authentication_token }.to_json, :status =&gt; :ok
    end
  end
  end
  end 
  </code></pre>
  
  <p>However when I try to run the application I get the following error:</p>
  
  <p>Routing Error
     uninitialized constant Managers</p>
  
  <p>What's causing this error? Any suggestions for how to correct this so that I can still log in via JSON?</p>
  
  <p>Thanks in advance for your help!</p>
  
  <p>Antony</p>