title: NoMethodError in Devise [Registrations & Sessions] undefined method `new' for nil:NilClass
body: <pre><code>Showing ...views/devise/sessions/new.html.erb where line #3 raised:
  
  undefined method `new' for nil:NilClass
  Extracted source (around line #3):
  
  &lt;h2&gt;Sign in&lt;/h2&gt;
  
  &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt;
  &lt;div&gt;&lt;%= f.label :email %&gt;&lt;br /&gt;
  &lt;%= f.email_field :email, :autofocus =&gt; true %&gt;&lt;/div&gt;
  </code></pre>
  
  <p>It is exactly the same case in <code>Registrations</code>, and at <strong>all</strong> devise routes we had configured in fact.</p>
  
  <p>It's not clear which recent change brought this on.</p>
  
  <p>We've tried:
  *</p>
  
  <ul>
  <li>List item</li>
  <li>db:reset</li>
  <li>reinstalling devise</li>
  <li>completely rebuilding all devise models and routes and tables</li>
  </ul>
  
  <p>It's always the same error:</p>
  
  <pre><code>undefined method `new' for nil:NilClass
  </code></pre>
  
  <p>Other questions on stackoverflow seem to be for other methods, e.g. <code>[]</code>, <code>new</code>, <code>authorize</code>... new for nil is the only one we're getting. Any ideas much appreciated.</p>
  
  <p>EDITS</p>
  
  <p>user.rb (model)</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :recoverable, :rememberable,   :trackable, :validatable
  
  has_many :journeys  # n.b: must pluralize here.
  end
  </code></pre>
  
  <p>routes (user routes)</p>
  
  <pre><code>user_registration_path   POST    /users(.:format)    devise/registrations#create
  PATCH    /users(.:format)    devise/registrations#update
  PUT  /users(.:format)    devise/registrations#update
  DELETE   /users(.:format)    devise/registrations#destroy
  users_path   GET     /users(.:format)    users#index
  POST     /users(.:format)    users#create
  </code></pre>
  
  <p>routes.rb
      devise_for :admins
      devise_for :users
      resources :users</p>
  
  <pre><code>get 'journeys', to: 'users#journeys'
  resources :journeys
  
  root to: "static#index"
  
  get '/journey/new', to: 'journeys#new'    # For some reason "resources :journeys"  isn't activating the new method.
  
  get '/admins/add_admin', to: 'admins#add_admin'
  
  devise_scope :user do
    get 'users/sign_out', to: 'session#destroy'
    # Don't need to define sign_in here, because it works already (unlike admin).
  end
  
  devise_scope :admin do 
    get 'admins/sign_out', to: 'devise/sessions#destroy'
    get 'admins/sign_in', to: 'devise/sessions#new'
  end
  </code></pre>