(postgreSQL错误)致命:角色“demo”不存在(PG ::错误)

时间:2013-05-04 19:38:57

标签: ruby-on-rails ruby-on-rails-3 postgresql

所以我刚刚用HomeBrew安装了postgreSQL,并使用: rails new demo_app -d postgresql 命令初始化了我的新demo_app。

虽然我在启动服务器 rails s 时遇到以下错误。

SNIPPIT

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': FATAL:  role "demo" does not exist (PG::Error)

完整日志:

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': FATAL:  role "demo" does not exist (PG::Error)
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `new'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `connect'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/anthonypanepinto/Sites/new_demo/demo/config/environment.rb:5:in `<top (required)>'
    from /Users/anthonypanepinto/Sites/new_demo/demo/config.ru:3:in `require'
    from /Users/anthonypanepinto/Sites/new_demo/demo/config.ru:3:in `block in <main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/anthonypanepinto/Sites/new_demo/demo/config.ru:in `new'
    from /Users/anthonypanepinto/Sites/new_demo/demo/config.ru:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

1 个答案:

答案 0 :(得分:3)

当你创建rails应用程序时,你必须使用postgres create a database才能使用它。

createdb demo

并检查您的config/database.yml