# Authentication and Wiki

**URL:** <https://www.ruby-forum.com/t/authentication-and-wiki/171578>\
**Category:** Rails\
**Created:** [July 6, 2009, 2:30am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578 "2009-07-06T02:30:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [July 6, 2009, 2:30am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578/1 "2009-07-06T02:30:17Z")

</div>

Hey, I’m trying as a test to make a simple wiki with RoR. I wanted to  
use restful\_authentication plugin, which creates a couple controllers,  
one of which is the Sessions controller. It has all the ‘logged\_in?’  
checks and the ‘current\_user’ variable. However, I don’t know how to use  
another controller’s variables/methods from within another controller.  
Ie, in my Wiki controller, or in it’s views, I can’t make these sort of  
calls to make sure the user is logged in. Can anyone guide me in the  
right direction?

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [July 6, 2009, 2:39am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578/2 "2009-07-06T02:39:06Z")

</div>

Tim M. wrote:

> Hey, I’m trying as a test to make a simple wiki with RoR. I wanted to  
> use restful\_authentication plugin, which creates a couple controllers,  
> one of which is the Sessions controller. It has all the ‘logged\_in?’  
> checks and the ‘current\_user’ variable. However, I don’t know how to use  
> another controller’s variables/methods from within another controller.  
> Ie, in my Wiki controller, or in it’s views, I can’t make these sort of  
> calls to make sure the user is logged in. Can anyone guide me in the  
> right direction?

restful\_authentication does provide all those extras, but they live in  
the .lib file, not in the controllers. You should be able to called  
logged\_in?, current\_user etc from any controller.

They key is to include the restful\_auth lib in application\_controller.  
As long as you do this, all the functionality will be available  
site-wide.

HTH

Matt

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [July 6, 2009, 2:42am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578/3 "2009-07-06T02:42:28Z")

</div>

Aah, so in the application controller, just a quick ‘include  
“restful\_auth”’ at the top o’ the file?

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [July 6, 2009, 3:04am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578/4 "2009-07-06T03:04:28Z")

</div>

Matt H. wrote:

> Tim M. wrote:
> 
> > Aah, so in the application controller, just a quick ‘include  
> > “restful\_auth”’ at the top o’ the file?
> 
> I believe it’s actually “include AuthenticatedSystem”. When you run  
> script/generate to make the restful\_auth controllers, it will put that  
> line at the top of the Sessions controller. The docs recommend you move  
> it to the application controller so it’s globally available.
> 
> HTH
> 
> Matt

Huh, I didn’t see that in the docs. Thanks for the help tho!

---

<div class="post-metadata">

**Author:** ![enchanter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce7236/32.png) [@enchanter](https://www.ruby-forum.com/u/enchanter)\
**Post date:** [July 6, 2009, 2:57am UTC](https://www.ruby-forum.com/t/authentication-and-wiki/171578/5 "2009-07-06T02:57:12Z")

</div>

Tim M. wrote:

> Aah, so in the application controller, just a quick ‘include  
> “restful\_auth”’ at the top o’ the file?

I believe it’s actually “include AuthenticatedSystem”. When you run  
script/generate to make the restful\_auth controllers, it will put that  
line at the top of the Sessions controller. The docs recommend you move  
it to the application controller so it’s globally available.

HTH

Matt
