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 8118007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:20:50+00:00 2026-06-06T04:20:50+00:00

NoMethodError in UsersController#show undefined method `signed_in?’ for #<UsersController:0x5bf3980> Rails.root: C:/test_app Application Trace | Framework

  • 0
NoMethodError in UsersController#show

undefined method `signed_in?' for #<UsersController:0x5bf3980>

Rails.root: C:/test_app
Application Trace | Framework Trace | Full Trace

app/controllers/users_controller.rb:91:in `signed_in_user'

Request
Parameters:
{"id"=>"1"}

Show session dump

Show env dump
Response

Headers:
None

In Users_Controller

    def signed_in_user
      redirect_to signin_path, notice: "Please Sign In." unless signed_in?
    end

In SessionsController

  def signed_in?
    !current_user.nil?
  end

module SessionsHelper

def sign_in(user)
   cookies.permanent.signed[:remember_token] = [user.id, user.salt]
   self.current_user = user
end

def sign_out
   cookies.delete(:remember_token)
   self.current_user = nil
end

 def current_user=(user)
       @current_user = user
 end

 def current_user
       @current_user ||= user_from_remember_token
 end

 def signed_in?
       !current_user.nil?
 end

 def create
         user = User.authenticate(params[:session][:email],
                                                          params[:session][:password])

         if user.nil?
                 flash.now[:error] = "Invalid email/password combination."
                 @title = "Sign In"
                 render 'new'
         else
             sign_in user
             flash.now[:error] = "Welcome, #{user.name}"
             render 'AdCon'
         end
 end

 def destroy
         sign_out
         redirect_to root_path
 end        

       private

               def user_from_remember_token
                       User.authenticate_with_salt(*remember_token)
               end

               def remember_token
                       cookies.signed[:remember_token] || [nil,nil]
               end  
end

*EDIT:*************************************************

I’m using the tutorial on:
http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users @ Listing 9.12

Listing 9.12. Adding a signed_in_user before filter.

app/controllers/users_controller.rb

class UsersController < ApplicationController
    before_filter :signed_in_user, only: [:edit, :update]
    .
    .
    .
    private

        def signed_in_user
             redirect_to signin_path, notice: "Please sign in." unless signed_in?
        end
end

When I included the helper in the SessionsController I received the message

undefined method `signed_in?’ for #
Extracted source (around line #9):

<div>
 <% if controller.signed_in?  %> <----LINE 9
 <%= link_to "Sign Out", signout_path, :method => :delete %>
 <% else %>
 <%= link_to "Sign IN" , signin_path %>

I included the Helper like this:
class SessionsController < ApplicationController
include SessionsHelper

I couldn’t get this to work, so I copied the helper methods into SessionsController and the error went away.and now I’m having an issue with 9.12 where signed_in? is an unknown method. and it makes sense because signed_in? is in SessionsController via a helper. can the UserController access that function. I’m new to rails and confused.

thanks for all the feedback

EDIT:******************

Here is the ApplicationController

class ApplicationController < ActionController::Base

  protect_from_forgery
  include ActionView::Helpers::SessionsHelper

  private

  def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
  end

  helper_method :current_user
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-06T04:20:51+00:00Added an answer on June 6, 2026 at 4:20 am

    You’re declaring your shared methods in the wrong place. signed_in? should be defined inside your ApplicationController, which is the shared base class for all your other controllers. There is, in essence, no way for you to do what you’re trying to do. The UsersController can’t access your SessionController‘s methods, nor should it be able to. That isn’t how controllers work.

    current_user, current_user=, and signed_in? all belong in your ApplicationController, not your SessionsController, because they’re shared methods meant to be used by all your controllers which inherit from ApplicationController.

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

Sidebar

Related Questions

In my rspec testing. I got NoMethodError: undefined method `password_digest='. But in rails console.
Rileshttps://gist.github.com/1265585 I'm getting an error (NoMethodError (undefined method `error' for true:TrueClass)) while trying to
If the results is nil then I get NoMethodError - undefined method 'length' for
When I write debugger it does not start: NoMethodError: undefined method `run_init_script' for Debugger:Module
When would Ruby ever throw a #<NoMethodError: undefined method '[]=' for nil:NilClass> when executing
NoMethodError in course_templates#index Showing app/views/course_templates/index.haml where line #6 raised: undefined method `new_course_template' for #<ActionView::Base:0x237c3e4>
Any idea why I am getting this error: Exception encountered: #<NoMethodError: undefined method `assert_valid_keys'
I get this error when trying to register a new user. NoMethodError (undefined method
NoMethodError in CarController#add undefined method `user_id=' for #<Car:0x7160c70> RAILS_ROOT: C:/Users/Jatinder/BitNami RubyStack projects/mercedes_mod 2 add.html
I am getting NoMethodError in SitesController#index undefined method `subdomain' for nil:NilClass I have an

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.