使用 Rpush 向我的 rails 3 应用程序添加推送通知时出错

Error adding push notifications to my rails 3 app using Rpush

我将 rpush gem 添加到我的 gem 文件并运行了 bundle install。根据文档,下一步是运行 rpush init。这给了我以下错误。

您没有指定您希望 Rails 如何报告您的 init 环境的弃用通知,请将 config.active_support.deprecation 设置为 :log、:notify 或 :stderr at config/environments/init.rb /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:inresolve_string_connection' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in spec' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:inestablish_connection' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in block (2 levels) in <class:Railtie>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:ininstance_eval' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in execute_hook' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:inblock in on_load' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in each' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:inon_load' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in block in <class:Railtie>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:30:ininstance_exec' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:30:in run' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:55:inblock in run_initializers' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:54:in each' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:54:inrun_initializers' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/application.rb:136:in initialize!' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:inmethod_missing' 来自 config/environment.rb:5:in <top (required)>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:inload' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in block in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/rpush-1.0.0/bin/rpush:31:in' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/rpush:23:in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/rpush:23:in' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in eval' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in'

然后我按照错误建议将一个 init.rb 文件添加到我的环境文件夹中。这是我添加到 init.rb

的内容
CityRails::Application.configure do
  config.active_support.deprecation = :log
end

然后我再次运行 rpush init 并收到以下错误

/Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:inresolve_string_connection' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in spec' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:inestablish_connection' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in block (2 levels) in <class:Railtie>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:ininstance_eval' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in execute_hook' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:inblock in on_load' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in each' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:inon_load' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in block in <class:Railtie>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:30:ininstance_exec' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:30:in run' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:55:inblock in run_initializers' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:54:in each' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/initializable.rb:54:inrun_initializers' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/application.rb:136:in initialize!' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:inmethod_missing' 来自 config/environment.rb:5:in <top (required)>' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:inload' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in block in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/gems/rpush-1.0.0/bin/rpush:31:in' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/rpush:23:in load' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/rpush:23:in' 来自 /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in eval' from /Users/mcarthur/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in'

请帮忙。我已经为此工作了 3 天。你们很棒。

编辑:我在 test/dev 环境中使用 sqlite3,在生产环境中使用 pg。

这是我的 database.yml 的样子:

development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000

test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000

production: adapter: postgresql encoding: unicode database: cityrails_production pool: 5

来自本地 rake 的输出 db:migrate -

数据库:/Users/mcarthur/Desktop/apps/city-rails/db/development.sqlite3

状态迁移 ID 迁移名称

up 20140423191412 创建用户 up 20140423191450 创建联系人 up 20140423191657 创建场地 up 20140423191730 创建城市 up 20140423194439 建立友谊 向上 20140423212732 创建邀请 up 20140423212915 添加默认邀请状态 向上 20140423213804 创建 kptwilios up 20140423221018 创建推送通知 up 20140423221315 创建设备令牌 向上 20140423221356 将默认添加到设备令牌环境 up 20140423225205 创建延迟工作 up 20140430001800 添加用户id到场地 向上 20140430001824 将 json 信息添加到场馆 up 20140616234552 将 api id 添加到场地 up 20140617012705 将用户标识覆盖添加到场地 up 20140617024603 给用户添加隐身模式 向上 20150107184219 阻止用户

heroku run rake 的输出 db:migrate -

数据库:dfvpbkpnbntg2f

状态迁移 ID 迁移名称

up 20140423191412 创建用户 up 20140423191450 创建联系人 up 20140423191657 创建场地 up 20140423191730 创建城市 up 20140423194439 建立友谊 向上 20140423212732 创建邀请 up 20140423212915 添加默认邀请状态 向上 20140423213804 创建 kptwilios up 20140423221018 创建推送通知 up 20140423221315 创建设备令牌 向上 20140423221356 将默认添加到设备令牌环境 up 20140423225205 创建延迟工作 up 20140430001800 添加用户id到场地 向上 20140430001824 将 json 信息添加到场馆 up 20140616234552 将 api id 添加到场地 up 20140617012705 将用户标识覆盖添加到场地 up 20140617024603 给用户添加隐身模式 向上 20150107184219 阻止用户

我尝试将 database.yml 文件从 cityrails_production 更改为 dfvpbkpnbntg2f,但没有成功。

database configuration does not specify adapter表示config/database.yml文件没有设置正确。有关该文件中应包含的内容的详细信息,请参阅 http://guides.rubyonrails.org/configuring.html#configuring-a-database

具体来说,错误信息指向找不到adapter: <database type>

https://gist.github.com/erichurst/961978 有一些 database.yml 的示例,您可以在设置时参考。

我在您的堆栈跟踪中看到 rpush-1.0.0。 1.0.0 已经很老了。请使用 2.2.0