title: Rails Devise Routes: If user signed in, point to index. Else, point to new user session
body: <p>Pretty simple question, but I can't seem to find the answer with a good ole fashioned Google.</p>
  
  <p><strong>The error:</strong></p>
  
  <pre><code>undefined method `user_signed_in?' for #&lt;ActionDispatch::Routing::Mapper:0x007fc6369320e8&gt; (NoMethodError)
  </code></pre>
  
  <p><strong>Server won't even start.</strong></p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>Rails.application.routes.draw do
  
  devise_for :users, :path_prefix =&gt; 'u'
  resources :users
  
    devise_scope :user do
      get "login", to: "devise/sessions#new", as: :login
      get 'logout', to: 'devise/sessions#destroy', as: :logout
      get 'user/edit', to: 'devise/registrations#edit', as: :change_password
    end
  
    resources :apps do
      resources :elements, controller: 'apps/elements'
    end
  
    resources :elements do
        resources :features, except: [:index], controller: 'apps/elements/features'
    end
  
  if user_signed_in?
    root to: 'apps#index'
  else
  devise_scope :user do
    root to: 'devise/sessions#new'
  end
  end
  
  end
  </code></pre>
  
  <p>What's the best way to go about making this work? I'm hesitant to try to work around it and make the site vulnerable, being a new RoR user. Thanks in advance.</p>