How do I use a helper inside a helper?

Hi.

Is there any way, that i can use a application_helper inside a
controller helper ?

http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000164

On Jan 23, 6:43 am, Emil K. [email protected]

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.

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). That should put you on the right track.

hth,
Bill

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

On Jan 24, 8:40 pm, Chris H [email protected] 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

On Jan 25, 7:59 am, “Bill W.” [email protected] wrote:

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

Thanks,
Bill

It’s a gem.

http://www.rubyforge.org/projects/ruby-units

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs