简体   繁体   English

使用Rpush将推送通知添加到我的Rails 3应用程序时出错

[英]Error adding push notifications to my rails 3 app using Rpush

I added the rpush gem to my gemfile and ran bundle install. 我将rpush gem添加到我的gemfile中,并进行了捆绑安装。 The next step according to the documentation is to run rpush init. 根据文档的下一步是运行rpush init。 This gave me the following error. 这给了我以下错误。

You did not specify how you would like Rails to report deprecation notices for your init environment, please set config.active_support.deprecation to :log, :notify or :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:in resolve_string_connection' from /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:in establish_connection' from /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:in instance_eval' from /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:in block in on_load' from /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:in on_load' from /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:in instance_exec' from /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:in block in run_initializers' from /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:in run_initializers' from /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:in method_missing' from 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:in load' from /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:in load_dependency' from /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 ' from /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 ' from /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 '

I then added an init.rb file into my environment folder that followed what the error suggested. 然后,我在环境文件夹中添加了一个init.rb文件,该文件遵循错误提示。 Here is what I added to init.rb 这是我添加到init.rb的内容

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

I then ran rpush init again and I'm getting the following error 然后,我再次运行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:in resolve_string_connection' from /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:in establish_connection' from /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:in instance_eval' from /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:in block in on_load' from /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:in on_load' from /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:in instance_exec' from /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:in block in run_initializers' from /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:in run_initializers' from /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:in method_missing' from 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:in load' from /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:in load_dependency' from /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 ' from /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 ' from /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 '

Please help. 请帮忙。 I've been working on this for 3 days. 我已经为此工作了3天。 You guys are great. 你们真棒。

Edit: I am using sqlite3 for test/dev environments and pg for production. 编辑:我正在使用sqlite3用于测试/开发环境和pg用于生产。

This is what my database.yml looks like: 这是我的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

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

database: /Users/mcarthur/Desktop/apps/city-rails/db/development.sqlite3

Status Migration ID Migration Name

up 20140423191412 Create users up 20140423191450 Create contacts up 20140423191657 Create venues up 20140423191730 Create cities up 20140423194439 Create friendships up 20140423212732 Create invitations up 20140423212915 Add default to invitations status up 20140423213804 Create kptwilios up 20140423221018 Create push notifications up 20140423221315 Create device tokens up 20140423221356 Add default to device token environment up 20140423225205 Create delayed jobs up 20140430001800 Add user id to venues up 20140430001824 Add json info to venues up 20140616234552 Add api id to venues up 20140617012705 Add user id override to venues up 20140617024603 Add incognito to users up 20150107184219 Block users

Output from heroku run rake db:migrate - heroku运行rake db:migrate的输出-

database: dfvpbkpnbntg2f

Status Migration ID Migration Name

up 20140423191412 Create users up 20140423191450 Create contacts up 20140423191657 Create venues up 20140423191730 Create cities up 20140423194439 Create friendships up 20140423212732 Create invitations up 20140423212915 Add default to invitations status up 20140423213804 Create kptwilios up 20140423221018 Create push notifications up 20140423221315 Create device tokens up 20140423221356 Add default to device token environment up 20140423225205 Create delayed jobs up 20140430001800 Add user id to venues up 20140430001824 Add json info to venues up 20140616234552 Add api id to venues up 20140617012705 Add user id override to venues up 20140617024603 Add incognito to users up 20150107184219 Block users

I tried changing my database.yml file from cityrails_production to dfvpbkpnbntg2f and it did not work. 我尝试将database.yml文件从cityrails_production更改为dfvpbkpnbntg2f,但它不起作用。

I see rpush-1.0.0 in your stacktrace. 我在您的堆栈跟踪中看到了rpush-1.0.0。 1.0.0 is very old. 1.0.0太旧了。 Please use 2.2.0 请使用2.2.0

database configuration does not specify adapter indicates that the config/database.yml file has not been set up correctly. database configuration does not specify adapter表明config/database.yml文件未正确设置。 See http://guides.rubyonrails.org/configuring.html#configuring-a-database for details about what should be in that file. 有关该文件中应包含的内容的详细信息,请参见http://guides.rubyonrails.org/configuring.html#configuring-a-database

Specifically, the error message is pointing to not finding adapter: <database type> 具体来说,错误消息指向找不到adapter: <database type>

https://gist.github.com/erichurst/961978 has some examples of database.yml that you could refer to while setting up one. https://gist.github.com/erichurst/961978提供了一些database.yml示例,您可以在设置示例时参考它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM