# NoMethodError in User sessionsController#new

**URL:** <https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465>\
**Category:** Rails\
**Created:** [October 18, 2009, 5:38am UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465 "2009-10-18T05:38:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 18, 2009, 5:38am UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465/1 "2009-10-18T05:38:56Z")

</div>

I’m setting up authentication with Authlogic and I get this error.  
I’ve done some searching but with no success. I tried setting the  
current\_user method in Application\_controller to protected and not  
private, on the recommendation in Stack Overflow.

Error in browser-----------------  
NoMethodError in User sessionsController#new

undefined method `require\_no\_user’ for #\<UserSessionsController:  
0x24fc700\>

Error in terminal------------------  
Processing UserSessionsController#new (for 127.0.0.1 at 2009-10-17  
23:26:38) [GET]  
Parameters: {“action”=\>“new”, “controller”=\>“user\_sessions”}

NoMethodError (undefined method `require\_no\_user’ for  
#UserSessionsController:0x24fc700):

Rendered rescues/\_trace (29.9ms)  
Rendered rescues/\_request\_and\_response (1.3ms)  
Rendering rescues/layout (internal\_server\_error)

* * *

FYI------------------------------------  
Rails version: 2.3.4  
Ruby version: 1.8.6

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 18, 2009, 5:57am UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465/2 "2009-10-18T05:57:40Z")

</div>

Hi Kevin

If I am getting it right then  
either  
you haven’t declared require\_no\_user in your application controller.  
or  
haven’t set up it before\_filter in application controller.

Please paste your code so that I can solve your problem precisely.

[http://blog.railsjaipur.in/](http://blog.railsjaipur.in/)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 18, 2009, 2:52pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465/3 "2009-10-18T14:52:36Z")

</div>

Here’s the code.

Application\_controller.rb---------------------------------  
class ApplicationController \< ActionController::Base  
filter\_parameter\_logging :password, :password\_confirmation  
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

```
protected
  def current_user
    return @current_user if defined?(@current_user)
    @current_user = current_user_session &&

```

current\_user\_session.user  
end

## end

Thanks for your help.

Kevin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 19, 2009, 3:51am UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465/4 "2009-10-19T03:51:41Z")

</div>

Thanks for your help. I fixed that and figured out another one myself.

I hope to enjoy it more, but it looks promising.

Kevin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 18, 2009, 6:46pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-user-sessionscontroller-new/177465/5 "2009-10-18T18:46:46Z")

</div>

Hi Kevin,

You have’t defined require\_user and require\_no\_user in your  
application controller.  
Please define them first.  
Go through the authlogic’s tutorial. Everything is defined there  
if you don’t find it there then I’ll get out of this error.

Hope you are enjoying RoR.

Bagwan Pankaj
