# Module accessing controller data

**URL:** <https://discuss.rubyonrails.org/t/module-accessing-controller-data/50936>\
**Category:** rubyonrails-talk\
**Created:** [April 15, 2010, 6:09pm UTC](https://discuss.rubyonrails.org/t/module-accessing-controller-data/50936 "2010-04-15T18:09:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ike](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Ike](https://discuss.rubyonrails.org/u/Ike)\
**Post date:** [April 15, 2010, 6:09pm UTC](https://discuss.rubyonrails.org/t/module-accessing-controller-data/50936/1 "2010-04-15T18:09:49Z")

</div>

I have data, :current\_user, in my Application Controller:

class ApplicationController \< ActionController::Base helper\_method :current\_user private &nbsp;&nbsp;&nbsp;def current\_associate &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return @current\_associate if defined?(@current\_associate) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@current\_associate = current\_associate\_session && current\_associate\_session.record &nbsp;&nbsp;&nbsp;&nbsp;end end

, so it is inherited by the controllers that inherit ApplicationController

I have a module, which is 'required' by several controllers who inherit from ApplicationController. One of controllers is descended from Application Controller -- another is not (it is descended from RuportController). The latter needs to access :current\_user.

What is the best way to accomplish this? (I have tried setting :current\_user in the module, so that the controller that is derived from RuportController might be able to call the module to obtain it, with no luck).

Ultimately, I need to get :current\_user into the controller derived from RuportController -- but how?

Thanks, R.Vince

---

<div class="post-metadata">

**Author:** ![Lasse\_Bunk](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@Lasse\_Bunk](https://discuss.rubyonrails.org/u/Lasse_Bunk)\
**Post date:** [April 15, 2010, 7:20pm UTC](https://discuss.rubyonrails.org/t/module-accessing-controller-data/50936/2 "2010-04-15T19:20:03Z")

</div>

Hi R. Vince,

What does RuportController inherit from?

/Lasse

---

<div class="post-metadata">

**Author:** ![Ike](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Ike](https://discuss.rubyonrails.org/u/Ike)\
**Post date:** [April 15, 2010, 7:32pm UTC](https://discuss.rubyonrails.org/t/module-accessing-controller-data/50936/3 "2010-04-15T19:32:12Z")

</div>

Lasse,

It doesn;t inherit anything:

class Ruport::Controller ... -R.Vince
