I had actually executed the command dpkg -s ruby It had given me the version as 4.2 When I did a ruby -v, it gave me the version as 1.8.7
l.lat will have some value such as 40.755970 l.lng will have some value such as -73.986702 But since they have been declared as Decimal(15,10), their values will be interpreted as 40.7559700000 and -73.9867020000 I have a database which consists of latitude and longitude of a few cities in US. So, this was just one example that I have given. Conrad Taylor wrote: > > On Sat, Mar 6, 2010 at 8:03 PM, mamathahl <[email protected]> wrote: > >> >> Conrad, >> The data type of l.lat and l.lng are same as that of lat_rad and lng_rad. >> They are declared as follows: >> >> t.decimal :lat, :precision => 15, :scale => 10 >> t.decimal :lng, :precision => 15, :scale => 10 >> >> The following lines are within the controller file named >> items_controller.rb >> >> t.lat_rad = (l.lat * BigDecimal.new("3.1415926536 / 180")).to_f >> t.lng_rad = (l.lng * BigDecimal.new("3.1415926536 / 180")).to_f >> >> I'm using Ruby version 4.2 on Ubuntu 8.10. >> The database I'm using is mysql. >> >> > Ruby version 4.2 doesn't exist. Please execute the following command > and post the results: > > ruby -v > > Next, what's the exact value of both l.lat and l.lng? > > -Conrad > > >> Conrad Taylor wrote: >> > >> > On Sat, Mar 6, 2010 at 4:39 PM, mamathahl <[email protected]> wrote: >> > >> >> >> >> I have been facing some problem with the datatypes. I have a sample >> of >> >> code >> >> as follows. >> >> >> >> t.lat_rad = (l.lat * BigDecimal.new("3.1415926536 / 180")).to_f >> >> t.lng_rad = (l.lng * BigDecimal.new("3.1415926536 / 180")).to_f >> >> >> >> Initially, the datatype of lat_rad and lng_rad was as follows: >> >> >> >> t.decimal :lat_rad, :precision => 15, :scale => 10 >> >> t.decimal :lng_rad, :precision => 15, :scale => 10 >> >> >> >> So, it gave me an error as follows: >> >> >> >> TypeError in ItemsController#populate >> >> >> >> wrong argument type BigDecimal (expected Float) >> >> >> >> Then I changed the data type of lat_rad and lng_rad to float. Even >> then >> >> it >> >> is giving me the same error. Any help to solve this problem will be >> >> appreciated. Thanks in advance. >> >> >> > >> > What's the type of >> > >> > l.lat >> > l.lng >> > >> > Also, are the following lines within a migration or controller file? >> > >> > t.lat_rad = (l.lat * BigDecimal.new("3.1415926536 / 180")).to_f >> > t.lng_rad = (l.lng * BigDecimal.new("3.1415926536 / 180")).to_f >> > >> > Lastly, what version of Ruby and which database you're using? >> > >> > -Conrad >> > >> > >> >> -- >> >> View this message in context: >> >> http://old.nabble.com/datatype-error-in-ROR-tp27808361p27808361.html >> >> Sent from the RubyOnRails Users mailing list archive at Nabble.com. >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "Ruby on Rails: Talk" group. >> >> To post to this group, send email to >> [email protected]. >> >> To unsubscribe from this group, send email to >> >> >> [email protected]<rubyonrails-talk%[email protected]> >> <rubyonrails-talk%[email protected]<rubyonrails-talk%[email protected]> >> > >> >> . >> >> For more options, visit this group at >> >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> >> >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Ruby on Rails: Talk" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > >> [email protected]<rubyonrails-talk%[email protected]> >> . >> > For more options, visit this group at >> > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/datatype-error-in-ROR-tp27808361p27808998.html >> Sent from the RubyOnRails Users mailing list archive at Nabble.com. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<rubyonrails-talk%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- View this message in context: http://old.nabble.com/datatype-error-in-ROR-tp27808361p27809867.html Sent from the RubyOnRails Users mailing list archive at Nabble.com. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

