# How do I use a helper inside a helper?

**URL:** <https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035>\
**Category:** Rails\
**Created:** [January 23, 2007, 6:43am UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035 "2007-01-23T06:43:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 23, 2007, 6:43am UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/1 "2007-01-23T06:43:16Z")

</div>

Hi.

Is there any way, that i can use a application\_helper inside a  
controller helper ?

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 23, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/2 "2007-01-23T13:50:17Z")

</div>

[http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000164](http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000164)

On Jan 23, 6:43 am, Emil K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 25, 2007, 2:41am UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/3 "2007-01-25T02:41:22Z")

</div>

Hi,

I am subtracting 2 times which gives me the time difference in seconds  
as a float.

How to I convert something like 3.815824 into 0:03 minutes?

Thanks in advance!

Cheers,  
Chris.

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 25, 2007, 4:16am UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/4 "2007-01-25T04:16:30Z")

</div>

Hi Chris,

> How to I convert something like 3.815824  
> into 0:03 minutes?

There’s nothing I know of ‘in the can’ for that level of granularity,  
but  
take a look at the source for distance\_of\_time\_in\_words helper (at  
[api.rubyonrails.org](http://api.rubyonrails.org)). That should put you on the right track.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 25, 2007, 2:00pm UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/5 "2007-01-25T14:00:47Z")

</div>

Hi Kevin,

\_Kevin wrote:

> require ‘ruby-units’
> 
> a = time1  
> b = time2  
> c = (time1 -time2).unit(‘min’)  
> c.to\_s(’%H:%M") #=\> ‘00:03’

That’s cool. Where is ruby-units documented?

Thanks,  
Bill

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [January 25, 2007, 5:28am UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/6 "2007-01-25T05:28:36Z")

</div>

On Jan 24, 8:40 pm, Chris H [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Chris.  
> require ‘rubygems’  
> require ‘ruby-units’

a = time1  
b = time2  
c = (time1 -time2).unit(‘min’)  
c.to\_s('%H:%M") #=\> ‘00:03’

This works well if you need to do math on the units, or if you have to  
deal with a wide variety of units.

\_Kevin

---

<div class="post-metadata">

**Author:** ![emuen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/96bed5/32.png) [@emuen](https://www.ruby-forum.com/u/emuen)\
**Post date:** [February 1, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/how-do-i-use-a-helper-inside-a-helper/83035/7 "2007-02-01T13:23:14Z")

</div>

On Jan 25, 7:59 am, “Bill W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> That’s cool. Where is ruby-units documented?
> 
> Thanks,  
> Bill

It’s a gem.

[http://www.rubyforge.org/projects/ruby-units](http://www.rubyforge.org/projects/ruby-units)
