小编Noa*_*vis的帖子

Geocoder Gem无法在生产环境中工作

因此,我使用Geocoder根据用户在提交表单时提供的地址提取纬度和经度坐标.我这样做是为了让我可以使用Google Maps API绘制标记.这在开发中非常有效 - 零问题.然而,当我推向生产时,Geocoder不会生成纬度和经度.我检查了我的生产日志,没有错误.我还检查确保gem不仅仅是为了开发安装而且我已经在我的生产机器上重新启动了unicorn和nginx.关于可能发生什么的任何想法?

这是我正在执行此任务的模型的模型代码 -

class Order < ActiveRecord::Base

  attr_accessible :city, :customer_email, :customer_id, :delivery_date, :delivery_time, :street, :zipcode, :coupon, :total, :name, :items_with_day, :user_id, :shopping_cart_id, :extras, :latitude, :longitude, :location_name, :phone, :suite, :state

  belongs_to :user

  validates :name, :presence => true
  validates :street, :presence => true
  validates :city, :presence => true
  validates :zipcode, :presence => true

  def address
    [street, city, state, "United States"].compact.join(', ')
  end

  geocoded_by :address
  after_validation :geocode

end
Run Code Online (Sandbox Code Playgroud)

============更新=============

所以在提出建议后,我在生产机器上打开了rails控制台 -

bundle exec rails console production
Run Code Online (Sandbox Code Playgroud)

跑了 - …

ruby ruby-on-rails production-environment rails-geocoder

3
推荐指数
1
解决办法
4015
查看次数

耙子流产了!对于确实存在的未初始化常数

我已经建立了一个rake任务 -

# SET RAKE TASK NAMESPACE
namespace :db do
# RAKE TASK DESCRIPTION
desc "Fetch property information and insert it into the database"

# RAKE TASK NAME    
task :insert_properties do

    # REQUIRE LIBRARIES
    require 'nokogiri'
    require 'open-uri'

    # OPEN THE XML FILE
    mits_feed = File.open("app/assets/xml/mits.xml")

    # OUTPUT THE XML DOCUMENT
    doc = Nokogiri::XML(mits_feed)

    # FIND PROPERTIES OWNED BY NORTHSTEPPE AND CYCLE THORUGH THEM
    doc.xpath("//Property/PropertyID/Identification[@OrganizationName='northsteppe']").each do |property|

        # GATHER EACH PROPERTY'S INFORMATION
        information = {
            "street_address" => property.xpath("/Address/AddressLine1/text()"),
            "city" => …
Run Code Online (Sandbox Code Playgroud)

ruby rake ruby-on-rails rake-task

2
推荐指数
1
解决办法
452
查看次数