Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:03:47+00:00 2026-06-04T06:03:47+00:00

I successfully use the gmaps4rails gem on my local MySQL machine. However, when I

  • 0

I successfully use the gmaps4rails gem on my local MySQL machine. However, when I deploy to PG on Heroku, I get the following error with respect to code that uses the gmaps4rails “near” function to find locations near the selected location:

2012-05-21T17:58:40+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  operator does not exist: numeric - character varying
2012-05-21T17:58:40+00:00 app[web.1]:                                                              ^
2012-05-21T17:58:40+00:00 app[web.1]: LINE 1: ...8.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.l...
2012-05-21T17:58:40+00:00 app[web.1]: HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
2012-05-21T17:58:40+00:00 app[web.1]: : SELECT  venues.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.latitude) * PI() / 180 / 2), 2) + COS(30.1926300 * PI() / 180) * COS(venues.latitude * PI() / 180) * POWER(SIN((-85.8356740 - venues.longitude) * PI() / 180 / 2), 2) )) AS distance, CAST(DEGREES(ATAN2( RADIANS(longitude - -85.8356740), RADIANS(latitude - 30.1926300))) + 360 AS decimal) % 360 AS bearing FROM "venues"  WHERE (3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.latitude) * PI() / 180 / 2), 2) + COS(30.1926300 * PI() / 180) * COS(venues.latitude * PI() / 180) * POWER(SIN((-85.8356740 - venues.longitude) * PI() / 180 / 2), 2) )) <= 5) ORDER BY distance LIMIT 5):
2012-05-21T17:58:40+00:00 app[web.1]:   app/controllers/venues_controller.rb:22:in `show'

I suspect that this is because of something not being supported in this query in postgres, but the gem supposedly supports postgres. Any idea what’s going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:03:48+00:00Added an answer on June 4, 2026 at 6:03 am

    Looks like PostgreSQL is complaining about this:

    30.1926300 - venues.latitude
    

    and the error message says that there is no operator that allows you to subtract a string from a number. I’d guess that you’ve created your venues.latitude column as a :string when it should be a :float or :decimal. MySQL tries to be friendly be doing a lot of implicit type conversions behind your back, PostgreSQL tries to be friendly by making you say exactly what you mean to avoid confusion.

    You’re going to have to change your latitude column to a numeric type. Then you should start developing on top of PostgreSQL if you’re going to deploy on top of Heroku’s PostgreSQL, you should also match the PostgreSQL version in your development and deployment environments.

    AFAIK, you’ll have to change the type manually with an ALTER TABLE as a simple change_column in a migration will probably fail with an error similar to

    column “latitude” cannot be cast to type double precision

    A migration like this:

    def up
        connection.execute(%q{
            alter table venues
            alter column latitude
            type float using latitude::float
        })
    end
    

    should do the trick for PostgreSQL. Presumably you’ll have to fix venues.longitude as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use newrelic in my project. I've installed newrelic gem successfully and
C is a QObject derived class, I can use it successfully. I get a
I've been able to successfully use the following workaround method: background: rgb(42,42,42); background: rgba(42,42,42,0.7);
I have a ant target where I successfully use a sshexec-task to install a
Background Our email vendor supports rss feeds for dynamic content, which we use successfully
I am trying to use the Google Map API- I've successfully managed to add
I was trying to use jQuery's page scroll inside some pages and could successfully
I use SpringSource Tool Suite 3.0.1, Tomcat server 7.0.21, maven-2.2.1. I successfully built my
I am successfully using Eclipse with emulators. Now I want to use my Defy
I created a DLL project and successfully built it. I then tried to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.