我有一个rails应用程序,我想在我的新笔记本电脑中部署它(新安装了ruby和rails)。
安装宝石和所有..当我转到我的rails应用程序文件夹和ruby rails s
错误显示如下:
/home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': FATAL: role "insane" does not exist (PG::Error)
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /home/insane/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /home/insane/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:308:in `clear_cache!'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activerecord-3.2.11/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418:in `_run__2015430698042624034__prepare__3529665547423141566__callbacks'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/insane/Rails/BACKUP/config/environment.rb:5:in `<top (required)>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /home/insane/Rails/BACKUP/config.ru:3:in `block in <main>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/insane/Rails/BACKUP/config.ru:in `new'
from /home/insane/Rails/BACKUP/config.ru:in `<main>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
from /home/insane/.rvm/gems/ruby-2.1.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我已经浏览了以下链接,但即使它有助于说/Rails/BACKUP$ createdb insane
createdb:无法连接到数据库postgres:致命:角色&#34;疯狂&#34;不存在
(postgreSQL error) FATAL: role "demo" does not exist (PG::Error)`
请帮忙
答案 0 :(得分:0)
您需要名为insane
的数据库中的用户。
打开终端并执行以下操作
($
和psql>
表示终端类型,而不是您键入的命令)
$ psql template1
psql> CREATE USER insane WITH PASSWORD 'some_password';
这应该为您创建用户。或者,如果这是在开发机器上,您可以使用
psql> CREATE USER insane superuser;
这将创建具有所有权限的用户insane
。
注意强>
您可能首先需要以postgres
用户身份登录。
$ sudo su postgres
<password for your account>
您不会看到输入的密码。
然后你就可以使用上面的第一组命令了。