我是rails的新手,我在Lynda.com上浏览了Kevin Skoglund的Ruby on Rails 3 Essential Training课程。通过课程,你设置了一个简单的cms,我做了。它不包括Git或部署,但我已将我的简单cms推送到github(https://github.com/nick5a1/Simple_CMS)并部署到Heroku(http://nkarrasch.herokuapp.com/)。
为了部署到Heroku,我遵循Heroku设置指南(https://devcenter.heroku.com/articles/rails3)并将我的数据库从MySQL切换到PostgreSQL。按照指示,我在我的Gemfile中将gen'mysql2'更改为gen'sqlite3'并在推送之前运行bundle install。然后我跑了heroku run rake db:migrate
。
我遇到了两个问题。当我尝试登录(http://nkarrasch.herokuapp.com/access)时,我收到错误“我们很抱歉,但出了点问题”。我应该使用无效的用户名/密码组合获取flash消息。这就是我在本地计算机上的测试环境中所获得的。
其次,当我登录Heroku控制台创建并创建管理员用户时,当我尝试保存该用户时,我收到以下错误:
irb(main):004:0> user.save
(1.2ms) BEGIN
AdminUser Exists (1.9ms) SELECT 1 AS one FROM "admin_users" WHERE "admin_users"."username" = 'Nick5a1' LIMIT 1
(1.7ms) ROLLBACK
=> false
有关如何排除故障的任何建议都将非常感激:)。
非常感谢, 尼克
编辑:这是我的Heroku日志:2012-06-27T20:36:44+00:00 heroku[slugc]: Slug compilation started
2012-06-27T20:37:34+00:00 heroku[api]: Add shared-database:5mb add-on by *
2012-06-27T20:37:34+00:00 heroku[api]: Release v2 created by *
2012-06-27T20:37:34+00:00 heroku[api]: Add RAILS_ENV, LANG, PATH, RACK_ENV, GEM_PATH config by *
2012-06-27T20:37:34+00:00 heroku[api]: Release v3 created by *
2012-06-27T20:37:34+00:00 heroku[api]: Release v4 created by *
2012-06-27T20:37:34+00:00 heroku[api]: Deploy 1d82839 by *
2012-06-27T20:37:35+00:00 heroku[slugc]: Slug compilation finished
2012-06-27T20:37:36+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 45450`
2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-06-27T20:37:44+00:00 app[web.1]: => Rails 3.2.6 application starting in production on http://0.0.0.0:45450
2012-06-27T20:37:44+00:00 app[web.1]: => Call with -d to detach
2012-06-27T20:37:44+00:00 app[web.1]: => Booting WEBrick
2012-06-27T20:37:44+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2012-06-27T20:37:44+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO WEBrick 1.3.1
2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO WEBrick::HTTPServer#start: pid=2 port=45450
2012-06-27T20:37:45+00:00 heroku[web.1]: State changed from starting to up
2012-06-27T20:39:44+00:00 heroku[run.1]: Awaiting client
2012-06-27T20:39:44+00:00 heroku[run.1]: Starting process with command `bundle exec rake db:migrate`
2012-06-27T20:39:44+00:00 heroku[run.1]: State changed from starting to up
2012-06-27T20:39:51+00:00 heroku[run.1]: Process exited with status 0
2012-06-27T20:39:51+00:00 heroku[run.1]: State changed from up to complete
2012-06-27T20:41:05+00:00 heroku[run.1]: Awaiting client
2012-06-27T20:41:05+00:00 heroku[run.1]: Starting process with command `bundle exec rails console`
2012-06-27T20:41:05+00:00 heroku[run.1]: State changed from starting to up
2012-06-27T20:46:09+00:00 heroku[run.1]: Process exited with status 0
2012-06-27T20:46:09+00:00 heroku[run.1]: State changed from up to complete
答案 0 :(得分:2)
您要宣布两个不同的数据库...尝试从Gemfile
gem 'pg'
gem 'mysql2'
并添加以下内容:
group :production do
gem 'pg'
gem 'thin'
end
group :development, :test do
gem 'mysql2'
end
通过这种方式,您将定义一个用于开发的数据库(mysql
)和另一个用于生产的数据库(<{1}})。
更改gemfile后:
pg
编辑 - 查看您的git add .
git commit -m "gemfile updated"
git push
git push heroku master
heroku run rake db:migrate
我意识到您使用的是routes.rb
,这会通过match ':controller(/:action(/:id))(.:format)'
请求提供您的所有操作。但是,我从未使用它,我认为你的路线可能有问题。
Jast确保它指向get
,是否可以包括由以下内容生成的路线:
access/attempt_login