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

  • Home
  • SEARCH
  • 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 6869305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:32:31+00:00 2026-05-27T03:32:31+00:00

The following code: class ApplicationController < ActionController::Base protect_from_forgery if user_signed_in? end end yields this

  • 0

The following code:

class ApplicationController < ActionController::Base
  protect_from_forgery

  if user_signed_in?
  end
end

yields this error:

undefined method `user_signed_in?' for ApplicationController:Class, Devise

I looked at this post but I don’t know what he means by instance of the application controller vs. definition of the application controller. I have devise_for :users set up in the config/routes.rb file, am not using clear_helpers, and have :database_authenticatable in my user.rb file. This if statement functions just fine if it’s in an action in a different controller. Why is it not working here? Do I need to pass the devise helper in somehow?

  • 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-05-27T03:32:31+00:00Added an answer on May 27, 2026 at 3:32 am

    He’s saying call the function using the controller class definition itself, not an instance of the controller class. In the code self == ApplicationController he is comparing self to the reference of the class definition ApplicationController rather than to a specific instance (or object) of ApplicationController.

    In this case, the post is essentially saying to call the debugger function within a method of the controller and not just somewhere in the definition of the controller.

    As the post mentions, you should be calling user_signed_in? within the context of an instance, not the definition. So put it in a method to be used for a before filter or something. For example:

    class ApplicationController < ActionController::Base
      protect_from_forgery
    
      def find_user_name
         if user_signed_in?
            return user.user_name
         end
      end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried the following ROR code: class SessionsController < ApplicationController def new end def
I have following code class User attr_accessor :name end u = User.new u.name =
With the following code : class TestsController < ApplicationController skip_before_filter :load_something, # how to
Take the following code: class ChallengesController < ApplicationController def update @challenge = Challenge.find(params[:id]) @challenge.update!(params[:challenge])
I tried the following code but it doesn't work class BlogsController < ApplicationController def
The following code: class Log: BAT_STATS = ['AB', 'R', 'H', 'HR'] def __init__(self, type):
The following code: class MyClass(): def test(self): self.__x = 0 def __setattr__(self, name, value):
Suppose I have the following code: class some_class{}; some_class some_function() { return some_class(); }
I have the following code: class IncidentTag: def __init__(self,tag): self.tag = tag def equals(self,obj):
Suppose I have the following code: class siteMS { ... function __CONSTRUCT() { require

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.