2015-01-16 51 views
1

我的Sinatra应用程序在使用sqlite进行本地安装时工作正常。当移动到Heroku的,我有奇怪的错误,所以我在本地的应用程序切换到Postgres的,也和我收到这些错误:加载中IRB模型时切换到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 

同样的情况。

这里是我的模型文件:

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上发布我的应用程序?

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

谢谢!

+0

你是在MAC吗? –

+0

是的,我在Mac上,但看起来问题是Ruby 2.2.0。切换回2.1.5解决了这个问题。去搞清楚。 –

回答

1

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

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

1

旧版本的pg gem与Ruby 2.2不兼容;你会想要更新到最新版本。有关更多详细信息,请参阅my answer to a similar question,其中包括更新说明。

+0

对不起布伦特,但我已经更新了宝石。事实上,我再次尝试,并检查我是'使用pg 0.18.1',但错误仍然存​​在。再次回到2.1.5。如果您有进一步的细节,请提供。我非常喜欢使用2.2.0,因为我已经读过关于性能改进的内容。 –

+0

作为一个数据点,我也遇到了这个问题(我有pg gem 0.14.0,并且最近升级到了Ruby 2.2),并且将pg gem更新为0.18.1为我解决了这个问题。 –