title: Devise after login redirect - double render error
body: <p>I'm working with rails 3.2 and Devise (the lastest version)</p>
  
  <p>The main idea if the test some variables of the current logged user after sign in. So, for example, if the user has pending creating an address i want to redirect the new address path. But what i get is a double render error.</p>
  
  <p>Here is the code</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery
  
   # Devise: Where to redirect users once they have logged in
    def after_sign_in_path_for(resource)
  
          if current_user.is? :company_owner
              if $redis.hget(USER_COMPANY_KEY, current_user.id).nil?
                  redirect_to new_owner_company_path and return
              else
                  @addr_pending = $redis.hget(PENDING_ADDRESS_KEY,current_user.id)
                  unless @addr_pending.nil? || !@addr_pending
                       redirect_to owner_company_addresses_path  and return
                  end
              end
          end
          root_path
    end
  end
  </code></pre>
  
  <p>my routes definition</p>
  
  <pre><code>  root :to =&gt; "home#index"
      devise_for :users, :controllers =&gt; { 
      :omniauth_callbacks =&gt; "users/omniauth_callbacks" 
    }
      resources :users, :only =&gt; :show
  
      namespace :owner do
          resource :company  do # single resource /owner/company
              get 'thanks'
              get 'owner' #TODO: esto hay que sacarlo de aquí y forme parte del login
              resources :addresses
          end
      end
  </code></pre>
  
  <p>So, when i login with a user with a pedding address creation i get</p>
  
  <pre><code>"render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".
  </code></pre>
  
  <p>what is wrong with?</p>
  
  <pre><code> redirect_to owner_company_addresses_path  and return
  </code></pre>
  
  <p>So, i just want to redirect to the new address path. I don't understand why i get the error.</p>
  
  <p>Thanks in advance.</p>
  
  <p>---- edit ----</p>
  
  <p>Seems that only one path must be returned (I thought with redirect_to and return was enough, but it does not)</p>
  
  <pre><code>def after_sign_in_path_for(resource)
  
          @final_url = root_path
          if current_user.is? :company_owner
              if $redis.hget(USER_COMPANY_KEY, current_user.id).nil?
                  @final_url = new_owner_company_path
              else
                  @addr_pending = $redis.hget(PENDING_ADDRESS_KEY,current_user.id)
                  unless @addr_pending.nil? || !@addr_pending
                       @final_url = owner_company_addresses_path
                  end
              end
          end
          @final_url
    end
  </code></pre>