undefined method `user_url' for Devise SessionsController:create
<p>I have user model for authorization with devise gem. I want to add after_sign_in_path method:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code># application_controller.rb

protected
# redirecting to appropriate url based on role
  def after_sign_in_path_for(resource)
    if current_user.has_role?(:admin)
      dashboard_path
    elsif current_user.has_role?(:student)
      root_path
    end
  end</code></pre>
</div>
</div>

Whenever I try to sign in I get this error:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>undefined method `user_url' for #&lt;Devise::SessionsController:0x007fb89b5b00a8&gt; Did you mean? course_url</code></pre>
</div>
</div>

I don't know why it says 'did you mean? course_url. But I have course model. And here are my routes:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>authenticate :user do

    resources :feeds, only: [:index]
    resources :courses, only: [:index, :show]    
    # etc...

  end</code></pre>
</div>
</div>
</p>

<p>Also here is the code it points me:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>if options.empty?
            recipient.send(method, *args)
  else
            recipient.send(method, *args, options)
  end</code></pre>
</div>
</div>
</p>

<p>and first line of log:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>actionpack (4.2.4) lib/action_dispatch/routing/polymorphic_routes.rb:220:in `polymorphic_method' </code></pre>
</div>
</div>
</p>

<p>Whenever I commend after_sign_in_path_for I am able to sign in. If I comment contents of after_sign_in_path_for but leave empty after_sign_in_path_for method, I also get this error.</p>

<p>EDIT: I tested that I am not also signed in, not just not redirected. I think error happens right in the call after_sign_in_path_for, not in the redirect_to or whatever. Probably it has to do something with resource.</p>

<p>EDIT2: here are my rake routes:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>  new_user_session GET    /users/sign_in(.:format)          devise/sessions#new
            user_session POST   /users/sign_in(.:format)          devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)         devise/sessions#destroy
           user_password POST   /users/password(.:format)         devise/passwords#create
       new_user_password GET    /users/password/new(.:format)     devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)    devise/passwords#edit
                         PATCH  /users/password(.:format)         devise/passwords#update
                         PUT    /users/password(.:format)         devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)           registrations#cancel
       user_registration POST   /users(.:format)                  registrations#create
   new_user_registration GET    /users/sign_up(.:format)          registrations#new
  edit_user_registration GET    /users/edit(.:format)             registrations#edit
                         PATCH  /users(.:format)                  registrations#update
                         PUT    /users(.:format)                  registrations#update
                         DELETE /users(.:format)                  registrations#destroy
       user_confirmation POST   /users/confirmation(.:format)     devise/confirmations#create
   new_user_confirmation GET    /users/confirmation/new(.:format) devise/confirmations#new
                         GET    /users/confirmation(.:format)     devise/confirmations#show
              admin_root GET    /                                 rails_admin/main#dashboard
            student_root GET    /                                 feeds#index
                   feeds GET    /feeds(.:format)                  feeds#index
                 courses GET    /courses(.:format)                courses#index
                  course GET    /courses/:id(.:format)            courses#show
                 schools GET    /schools(.:format)                schools#index
                  school GET    /schools/:id(.:format)            schools#show
            universities GET    /universities(.:format)           universities#index
              university GET    /universities/:id(.:format)       universities#show
             rails_admin        /admin                            RailsAdmin::Engine
                         POST   /graphql(.:format)                graphql#create
    landing_confirmation GET    /landing/confirmation(.:format)   landing#confirmation
   landing_access_denied GET    /landing/access_denied(.:format)  landing#access_denied
                    root GET    /                                 landing#index</code></pre>
</div>
</div>
</p>

<p>EDIT3: here is my github repo: </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>https://github.com/yerassyl/nurate</code></pre>
</div>
</div>
</p>