Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've implemented Authlogic in my Rails 4 app. I can connect to my LDAP server and authenticate with my AD username and password. But, I cannot call "current_user" anywhere in the app.

For instance, when I call Welcome, <%= current_user.first_name %>

I get: undefined method 'first_name' for nil:NilClass

class ApplicationController < ActionController::Base

  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.

  helper :all
  protect_from_forgery with: :exception


  helper_method :current_user_session, :current_user

  private
    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.user
    end

end

Any ideas are appreciated. Thanks! Katie

share|improve this question

4 Answers 4

up vote 0 down vote accepted

Authlogic, as of today, is not ready for Rails 4:

http://ready4rails4.net/

Name: authlogic
Status: not ready
Notes: pull request

share|improve this answer

Authlogic is working for my Rails 4 app. current_user works just fine. You may want to try it again.

share|improve this answer

Authlogic is now working. if there are issues, provide the following in your gemfile:

gem 'authlogic', github: 'binarylogic/authlogic', ref: 'e4b2990d6282f3f7b50249b4f639631aef68b939'

share|improve this answer

@rhuppert, that particular authlogic commit really saved my bacon, thank you for sharing that information. Turns out the newer Authlogic versions, 3.3.0 and 3.4.0, no longer work with one of my Rails 4.0.x apps, but when I use the version you mention (gem 'authlogic', github: 'binarylogic/authlogic', ref: 'e4b2990d6282f3f7b50249b4f639631aef68b939') it works with Rails 4.0.x. The error I was getting with both Authlogic 3.4.0 and 3.8.0 was (line from Rails logger):

F, [2014-03-04T07:25:09.640105 #28602] FATAL -- : NameError (uninitialized constant SCrypt):
  app/controllers/user_sessions_controller.rb:15:in `create'

Thanks again!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                  <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2015 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2015.5.6.2556\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nosc"], "copyright__copyright__copyright": [" with Rails 4.0.x. The error I was getting with both Authlogic 3.4.0 and 3.8.0 was (line from Rails logger):\n\nF, [2014-03-04T07:25:09.640105 #28602] FATAL -- : NameError (uninitialized constant SCrypt):\n  app/controllers/user_sessions_controller.rb:15:in `create'\n\nThanks again!\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}