# Main Object error

**URL:** <https://www.ruby-forum.com/t/main-object-error/175604>\
**Category:** Rails\
**Created:** [September 16, 2009, 1:17pm UTC](https://www.ruby-forum.com/t/main-object-error/175604 "2009-09-16T13:17:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashanth\_hiremath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df705f/32.png) [@prashanth\_hiremath](https://www.ruby-forum.com/u/prashanth_hiremath)\
**Post date:** [September 16, 2009, 1:17pm UTC](https://www.ruby-forum.com/t/main-object-error/175604/1 "2009-09-16T13:17:17Z")

</div>

Hi i am applying the formula to find the surrounding distance within 10  
km  
using ruby

geokit

x=((((acos(sin((’#{lat}’\*pi()/180)) \*  
sin((`latitude`\*pi()/180))+cos((’#{lat}’\*pi()/180)) \*  
cos((`latitude`\*pi()/180)) \* cos(((’#{lng}’-  
`longitude`)\*pi()/180))))_180/pi())601.1515_1.609344) \<= 10)

NoMethodError: undefined method `pi’ for main:Object

Am getting this error help me to solve this.ANd morever i ma not  
connected  
to any databse\

Regsrda  
prashanth

---

<div class="post-metadata">

**Author:** ![prashanth\_hiremath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df705f/32.png) [@prashanth\_hiremath](https://www.ruby-forum.com/u/prashanth_hiremath)\
**Post date:** [September 16, 2009, 1:37pm UTC](https://www.ruby-forum.com/t/main-object-error/175604/2 "2009-09-16T13:37:12Z")

</div>

Use Math::PI; please use Google more often.

BTW, I hope you understand sin(‘#{lat}’) is also wrong because of  
multiple reasons - but if you don’t, I should leave it to you to  
figure out.

–  
à¤…à¤­à¤¿à¤¨à¤µ  
[http://twitter.com/abhinav](http://twitter.com/abhinav)

2009/9/16 prashanth hiremath [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
