# Access library from model

**URL:** <https://www.ruby-forum.com/t/access-library-from-model/139690>\
**Category:** Rails\
**Created:** [June 6, 2008, 3:59am UTC](https://www.ruby-forum.com/t/access-library-from-model/139690 "2008-06-06T03:59:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [June 6, 2008, 3:59am UTC](https://www.ruby-forum.com/t/access-library-from-model/139690/1 "2008-06-06T03:59:15Z")

</div>

Hello,  
I have a custom library in lib that handles remote authentication to  
our  
external auth system via soap. All works well from the controller.  
However, I feel all this logic should be moved to the model but I dont  
know how to invoke a method in a library Module from a model. Is this  
possible? Last resort is to move this logic into the controller, but  
that  
just seems to break MVC

Thx  
Adam

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [June 6, 2008, 4:38am UTC](https://www.ruby-forum.com/t/access-library-from-model/139690/2 "2008-06-06T04:38:28Z")

</div>

Hi,

Authentication generally isn’t a domain responsibility. Thus, I  
wouldn’t put something like that in a model. Also, the authentication  
logic itself probably doesn’t belong in the controller. Rather, the  
controller can invoke a method on the lib to authenticate the user. If  
this is what you’re doing already, what’s bothering you about it?

Craig

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [June 6, 2008, 5:44am UTC](https://www.ruby-forum.com/t/access-library-from-model/139690/3 "2008-06-06T05:44:35Z")

</div>

I guess more because I am used to the authenticate methods being in the  
model with restful\_authentication , etc.  
Currently using a lib file loaded into a controller and calling a method  
from there, so I guess we are OK. Felt strange for some reason.

Adam

On Thu, Jun 5, 2008 at 10:37 PM, Craig D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
