如何告诉heroku为新创建的应用程序使用rails 3和ruby 1.9.2?
我使用 rvm ruby1.9.2p0 和 Rails 3.0.1 在我的计算机上创建了一个新应用程序,并执行了以下操作:
rails new -J -d mysql appname
git init
git add .
git commit
heroku create
并且创建了该应用程序。但当我这样做时:
heroku rake db:create --trace
我得到:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql2", "database"=>"app_production", "pool"=>5, "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock"}, charset: utf8, collation: utf8_unicode_ci
(in /app)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
当我这样做时: heroku rake db:migrate --trace,然后跟踪有如下行:
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
显示它正在使用 ruby 1.8 而不是 ruby 1.9.2
如何在我的 heroku 应用程序上创建数据库并使其使用 ruby 1.9.2p0?
I created a new app on my machine using rvm ruby1.9.2p0 and rails 3.0.1, and did the following:
rails new -J -d mysql appname
git init
git add .
git commit
heroku create
and the app is created. but when i do:
heroku rake db:create --trace
I get:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql2", "database"=>"app_production", "pool"=>5, "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock"}, charset: utf8, collation: utf8_unicode_ci
(in /app)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
and when i do:
heroku rake db:migrate --trace, then the trace has lines like:
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
which shows it is using ruby 1.8 instead of ruby 1.9.2
How can I create a database on my heroku app and make it use ruby 1.9.2p0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经在 Heroku 上创建了应用程序,正如您所发现的,它将默认为 1.8.7。您可以在创建应用程序时指定要在其上创建应用程序的堆栈;
要将您的应用程序迁移到 1.9.2,您需要发出
一旦迁移,您将需要重新推送您的应用程序(如果我没记错的话)
If you've already created the application on Heroku it will have defaulted to 1.8.7 as you've found. You can specify the stack to create the application on when you create your app;
To migrate your app to 1.9.2 you will need to issue
Once migrated you will need to repush your application (if i remember correctly)
问题不在于 Ruby 或 Rails 版本。
这里的问题是,您正在尝试使用 MySQL,而 Heroku 仅支持 PostgreSQL。
在此页面中,您可以找到迁移到其他 Heroku 堆栈的说明。
The problem is not the Ruby or Rails version.
The problem here is that you are trying to use MySQL while Heroku only supports PostgreSQL.
In this page you can find the instructions to migrate to a different Heroku stack.