应用程序切换到Postgres后停止工作

时间:2015-01-16 17:21:36

标签: sqlite postgresql heroku sinatra datamapper

我的Sinatra应用程序在使用sqlite进行本地安装时工作正常。当移动到Heroku时,我遇到了奇怪的错误,所以我也在我的本地应用程序中切换到Postgres,我收到了这些错误:

dyld: lazy symbol binding failed: Symbol not found: _rb_thread_select
  Referenced from: /Users/Emanuele/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/do_postgres-0.10.14/do_postgres/do_postgres.bundle
  Expected in: flat namespace

dyld: Symbol not found: _rb_thread_select
  Referenced from: /Users/Emanuele/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/do_postgres-0.10.14/do_postgres/do_postgres.bundle
  Expected in: flat namespace

在irb。

中加载模型时会发生同样的情况

这是我的模型文件:

require 'data_mapper'
require 'dm-types'
require 'dm-validations'
require 'dm-postgres-adapter'
require 'bcrypt'

# Setup DataMapper with a database URL. Will use ENV['DATABASE_URL'] on Heroku.
DataMapper.setup(:default, 'postgres://localhost/myapp')

# Let's define the model
class User
  include DataMapper::Resource
  include BCrypt

  property :id, Serial, :key => true
  property :email, String, :length => 5..70, :unique => true, :required => true, :format => :email_address
  property :password, BCryptHash
  property :account_sid, String, :length => 34
  property :auth_token, String, :length => 32
  property :app_sid, String, :length => 34

  def authenticate(attempted_password)
    if self.password == attempted_password
      true
    else
      false
    end
  end

end

# Finalize the DataMapper model.
DataMapper.finalize

# Tell DataMapper to update the database according to the definitions above.
DataMapper.auto_upgrade!

当我切换回sqlite3时,应用程序再次开始工作。我无法设法找出错误。在线搜索没有产生任何结果。

有没有人知道发生了什么以及我如何解决这个问题并在Heroku上发布我的应用程序?

如果您需要更多信息,请询问。

谢谢!

2 个答案:

答案 0 :(得分:1)

看起来从2.2.0切换回Ruby 2.1.5解决了本地和Heroku上的问题。看看出了什么问题。

如果更有经验的开发人员想要追踪错误并需要我提供一些信息,请询问。

答案 1 :(得分:1)

pg gem的旧版本与Ruby 2.2不兼容;您想要更新到最新版本。有关详情,请参阅my answer to a similar question,包括更新说明。

相关问题