Hi,
Is it possible to test helper/view methods from script/console. I want
to test the output of methods like distance_of_time_in_words. But it
won’t let me from the console. What am I missing?
TIA
Luke
Hi,
Is it possible to test helper/view methods from script/console. I want
to test the output of methods like distance_of_time_in_words. But it
won’t let me from the console. What am I missing?
TIA
Luke
On Feb 3, 2008, at 6:56 PM, Luke G. wrote:
Hi,
Is it possible to test helper/view methods from script/console. I want
to test the output of methods like distance_of_time_in_words. But it
won’t let me from the console. What am I missing?TIA
Luke
User the helper object:
helper.distance_of_time_in_words 92.minutes
=> “about 2 hours”
-Rob
On 3 Feb 2008, at 23:56, Luke G. wrote:
Hi,
Is it possible to test helper/view methods from script/console. I want
to test the output of methods like distance_of_time_in_words. But it
won’t let me from the console. What am I missing?
you need to include the appropriate module eg:
Fs-ElephantBook:fred fred$ ruby script/console
Loading development environment (Rails 2.0.2)
require ‘action_view/helpers/date_helper’
=> []include ActionView::Helpers::DateHelper
=> Objectdistance_of_time_in_words_to_now Time.mktime(2008,2,3,4)
=> “about 20 hours”
On 4 Feb 2008, at 00:14, Rob B. wrote:
won’t let me from the console. What am I missing?
TIA
LukeUser the helper object:
helper.distance_of_time_in_words 92.minutes
=> “about 2 hours”
Neato! I’ve somehow managed to miss that one!
Fred
Awesome. Exactly what I was looking for.
Thanks!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs