Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:46:36+00:00 2026-06-01T19:46:36+00:00

I have extended the devise controller for sessions. To add some extra functionality when

  • 0

I have extended the devise controller for sessions. To add some extra functionality when a user logs in. Now upon login, IF no username or password are entered I get error :
SessionsController#create

Called id for nil, which would mistakenly be 4 — if you really wanted the id of nil, use object_id

I searched last week for up to 2 hours how to fix this anyone can help me out on this one? Would be highly appreciated

How to correctly add my custom functionality but still preserve the Devise create action?

class SessionsController < Devise::SessionsController

  def create

    @user = User.where(:id => current_user.id).first
    @moderated = Asset.where(:attachable_id => current_user.id, :moderated => true).first

    if @user.sign_in_count.to_i == 1
      def after_sign_in_path_for(resource)
        "/welcome/basics"
      end
    else
      if @moderated.nil?
        unless @user.has_photo?
          def after_sign_in_path_for(resource)
          "/home/no_photo"
          end
        end
      else
        def after_sign_in_path_for(resource)
          "/home/moderated"
        end
      end
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:46:37+00:00Added an answer on June 1, 2026 at 7:46 pm

    If your additional functionality consists of redirecting the user to a different page at his first login i would suggest defining after_sign_in_path_for in the application controller as suggested by the wiki.

    class ApplicationController < ActionController::Base
    
      private
    
      def after_sign_in_path_for(resource)
        if current_user.sign_in_count == 1
          "/welcome/basics"
        else
          "/other/path"
        end
      end
    
    end
    

    Please note that this only works if User is the only resource that can sign into your application. Otherwise you would have to differentiate in this method as well via the resource parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have extended a MaskedTextBox component to add some functionality. The text property of
I have extended a server control (not a user control) and put the code
I have extended Django's User Model using a custom user profile called UserExtension .
I have extended the standard FileSystemWatcher class by adding a string property (fileToTest), now
I have extended the android View class, and now I want to define a
I have extended the RichTextBox control to implement much of the missing functionality provided
I have extended the Mage_Adminhtml_Block_Sales_Order_Grid class with a custom module to add several customer
I have extended User via AUTH_PROFILE_MODULE to include a ManyToMany field to Projects the
I have extended the menu_custom table in drupal to add role1, role2 and role3
I have 'extended' the System.DateTime struct by adding some essential fields to it. Ideally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.