【问题标题】:Ruby on Rails - how can I open project with postgres?Ruby on Rails - 如何使用 postgres 打开项目?
【发布时间】:2016-11-16 11:50:01
【问题描述】:

最后一天我得到了一个 ruby​​ on rails 项目。知道我的问题:如何打开这个项目(使用 postgres)。

更多信息: 我的贡献是 Windows。 Ruby 和 Rails 都已安装。

  1. 首先我通过 cmd 导航到我的项目文件夹

  2. 我使用此提示“bundle install”安装 gemfiles

  3. 之后我尝试使用此提示符“rails server”运行瘦服务器

现在我收到数据库混乱的消息。 Database.yml 存在于 config 文件夹中。

有人可以帮助我吗?

【问题讨论】:

  • 我要尝试的第一件事是确保 config/database.yml 对您的数据库具有正确的配置。尝试使用该配置中的凭据、数据库名称、主机和端口在命令行运行 postgres。在这里查看如何运行该工具:postgresql.org/docs/8.4/static/app-psql.html

标签: ruby-on-rails postgresql rails-postgresql heroku-postgres


【解决方案1】:

如果您从头开始,一个选项是生成一个全新的 Rails 应用程序,其中 postgresql 已设置为默认数据库。

从命令行:rails new MyApp --database=postgresql

然后用你的gemfile进入项目目录cd MyApp,bundle install,然后创建并迁移数据库并运行服务器:

bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rails server   

既然您标记了 Heroku,请查看来自 heroku 的 guide 以获取更多详细信息

希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    相关资源
    最近更新 更多