# How to write and call helpers from server/console?

**URL:** <https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827>\
**Category:** Rails\
**Created:** [August 6, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827 "2010-08-06T14:02:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 6, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827/1 "2010-08-06T14:02:17Z")

</div>

I need a helper function to read cvs data into my database. I do not  
need this function later in the web application.

My idea was to write a function inside a controller or AcriveRecord  
class. But I dont get it called via server/console.

How do do this?

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 6, 2010, 3:33pm UTC](https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827/2 "2010-08-06T15:33:41Z")

</div>

Fritz T. wrote:

> I need a helper function to read cvs data into my database. I do not  
> need this function later in the web application.
> 
> My idea was to write a function inside a controller or AcriveRecord  
> class. But I dont get it called via server/console.
> 
> How do do this?

Make it a migration?

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 6, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827/3 "2010-08-06T16:26:38Z")

</div>

Ar Chron wrote:

> Make it a migration?

A migration to import data?

I want to run an arbitrary function in the context of my application.

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 6, 2010, 4:36pm UTC](https://www.ruby-forum.com/t/how-to-write-and-call-helpers-from-server-console/192827/4 "2010-08-06T16:36:52Z")

</div>

Fritz T. wrote:

> I need a helper function to read cvs data into my database. I do not  
> need this function later in the web application.
> 
> My idea was to write a function inside a controller or AcriveRecord  
> class.

These are both probably the wrong place for it. You probably want a  
non-AR class or module to hold at least some of the code.

> But I dont get it called via server/console.
> 
> How do do this?

You may have to load the relevant class or include the relevant module.  
But it probably should be a Rake task…

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
