Forum: Ruby on Rails irb with rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
kevin (Guest)
on 2006-02-23 07:44
I was trying to access rails functions (number_with_precision) from an
irb session.

It can't find the method.  How do I load the libraries ?

TIA
LS
Zed S. (Guest)
on 2006-02-23 08:10
(Received via mailing list)
Try this instead:

script/console

That's basically what you want.

Zed
kevin (Guest)
on 2006-02-23 08:25
Thanks Zed,
This is the error I got when I tried that.

>> p number_with_precision(1.2334,2)
NoMethodError: undefined method `number_with_precision' for
#<Object:0x27891f8>
        from (irb):1

Do I need to do a 'require' ?

Zed S. wrote:
> Try this instead:
>
> script/console
>
> That's basically what you want.
>
> Zed
Mikkel B. (Guest)
on 2006-02-23 10:35
(Received via mailing list)
On Thursday, February 23, 2006, at 7:25 AM, kevin wrote:
>Thanks Zed,
>This is the error I got when I tried that.
>
>>> p number_with_precision(1.2334,2)
>NoMethodError: undefined method `number_with_precision' for
>#<Object:0x27891f8>
>        from (irb):1
>
>Do I need to do a 'require' ?
>
Yeah, i believe its in one of the helpers...

Mikkel B.

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
Simo A. (Guest)
on 2006-02-23 11:41
kevin wrote:
> I was trying to access rails functions (number_with_precision) from an
> irb session.
>
> It can't find the method.  How do I load the libraries ?
>
> TIA
> LS

Using script/console:
  >ruby script\console
  Loading development environment.
  >> include ActionView::Helpers::NumberHelper
  => Object
  >> number_with_precision(111.2345)
  => "111.235"
  >>

Using irb:
  >irb
  irb(main):001:0> require 'rubygems'
  => false
  irb(main):002:0> require 'initializer'
  => true
  irb(main):003:0> include ActionView::Helpers::NumberHelper
  => Object
  irb(main):004:0>  number_with_precision(111.2345)
  => "111.235"


Simo
 Addsw.it
Mikkel B. (Guest)
on 2006-02-23 11:47
(Received via mailing list)
nice

Mikkel B.

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
kevin (Guest)
on 2006-02-23 11:53
Wow, I tried and gave up - got everything but the "require
'initializer'"

Thanks.

Simo Gal wrote:
> kevin wrote:
>> I was trying to access rails functions (number_with_precision) from an
>> irb session.
>>
>> It can't find the method.  How do I load the libraries ?
>>
>> TIA
>> LS
>
> Using script/console:
>   >ruby script\console
>   Loading development environment.
>   >> include ActionView::Helpers::NumberHelper
>   => Object
>   >> number_with_precision(111.2345)
>   => "111.235"
>   >>
>
> Using irb:
>   >irb
>   irb(main):001:0> require 'rubygems'
>   => false
>   irb(main):002:0> require 'initializer'
>   => true
>   irb(main):003:0> include ActionView::Helpers::NumberHelper
>   => Object
>   irb(main):004:0>  number_with_precision(111.2345)
>   => "111.235"
>
>
> Simo
>  Addsw.it
This topic is locked and can not be replied to.