2015-01-16 49 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爲我解決了這個問題。 –