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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:08:54+00:00 2026-06-13T02:08:54+00:00

I thought the helper:all in the following application.rb would make current_user available to every

  • 0

I thought the helper:all in the following application.rb would make current_user available to every controller and view?

class ApplicationController < ActionController::Base

  helper :all
  protect_from_forgery
  before_filter { |c| Authorization.current_user = c.current_user }

  def current_user_session
    return @current_user_session if defined?(@current_user_session)
    @current_user_session = UserSession.find
  end

  def current_user
    return @current_user if defined?(@current_user)
    @current_user = current_user_session && current_user_session.record
  end

  ...

  private

  ...

  protected

  ...

end

My views call the current_user method like this:

- if current_user
  = link_to "Logout", logout_path

For which I get this response:

undefined local variable or method `current_user' for #<#<Class:0x007f971d812a48>:0x007f972050c378>

What am I missing?

Many thanks,

Steven.

PS I have experimented with this in the controller tied to the view that is failing:

before_filter :current_user
  • 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-13T02:08:55+00:00Added an answer on June 13, 2026 at 2:08 am

    From the doc:

    When the argument is the symbol :all, the controller will include all
    helpers beneath ActionController::Base.helpers_dir (defaults to
    app/helpers/*/.rb under RAILS_ROOT).

    You’re looking for:

    helper_method :current_user, :current_user_session
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an helper class with some static functions. All the functions in the
I need to test the following helper: def display_all_courses @courses = Course.all output =
So I thought I'd write my first codeigniter helper (still new to codeigniter somewhat).
Thought my range of search options would easily find this. I wish to combine
I thought the following script will create div element but I got nothing output
I thought I would be smart and create member functions that accepted output iterators.
I thought this would be fairly simple but it turns out not to work
I've just been browsing and spotted the following... When should you use a class
I have an existing class library with all the classes to communicate with my
A project I'm currently working on requires the application to discover all audio tracks

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.