# Helpers in Models

**URL:** <https://www.ruby-forum.com/t/helpers-in-models/162764>\
**Category:** Rails\
**Created:** [March 13, 2009, 2:34pm UTC](https://www.ruby-forum.com/t/helpers-in-models/162764 "2009-03-13T14:34:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitespace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f19dbf/32.png) [@whitespace](https://www.ruby-forum.com/u/whitespace)\
**Post date:** [March 13, 2009, 2:34pm UTC](https://www.ruby-forum.com/t/helpers-in-models/162764/1 "2009-03-13T14:34:54Z")

</div>

I have an app that relies on a series of helpers to generate language  
specific text strings for all output.

In one of my models I have to save one of these language specific  
strings to the table.  
Therefore I’ve started investigating how I can accesss my helpers in my  
model - I know this is not best practise, but its the only way I can see  
to make this work.

I know of the solution with including the helper in the model like this:

class Employee \< ActiveRecord::Base  
include LanguageHelper  
end

But this is not that good performance wise?

How do I reach my helpers in the model in a more efficient way?  
Or can I construct my code in a more correct way?

Best regards  
Rudi

---

<div class="post-metadata">

**Author:** ![whitespace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f19dbf/32.png) [@whitespace](https://www.ruby-forum.com/u/whitespace)\
**Post date:** [March 13, 2009, 2:56pm UTC](https://www.ruby-forum.com/t/helpers-in-models/162764/2 "2009-03-13T14:56:41Z")

</div>

Rudi W. wrote:

> Therefore I’ve started investigating how I can accesss my helpers in my  
> model - I know this is not best practise, but its the only way I can see  
> to make this work.

So your idea here is to fix a bad practice by using an even worse  
practice?

> How do I reach my helpers in the model in a more efficient way?  
> Or can I construct my code in a more correct way?

Dealing with languages is a view specific tasks. Models should not be  
concerned with language specific issues, In my view the pain this is  
giving you should be viewed like a “toothache.” Your code is trying to  
tell you something is fundamentally wrong. Using pain relievers, might  
get you by for a time, but eventually the problem will need to be  
addresses at the source.

However, if you have code that needs to be shared between the MVC layers  
it’s common practice to put that code in modules inside the lib  
directory, which is provided for just this sort of sharing. That doesn’t  
mean, however, that lib is intended to be a “free zone” where rules of  
MVC don’t matter and you’re free to break it at will.
