0

私は 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た。

私は2つの問題に直面しています。ログインしようとすると ( http://nkarrasch.herokuapp.com/access )、「申し訳ありませんが、問題が発生しました」というエラーが表示されます。代わりに、無効なユーザー名とパスワードの組み合わせを含むフラッシュ メッセージが表示されるはずです。これは、ローカル マシンのテスト環境で取得しているものです。

次に、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
4

1 に答える 1

2

2 つの異なるデータベースを宣言しています... から次の 2 行を削除してみてくださいGemfile:

gem 'pg'
gem 'mysql2'

そして、以下を追加します:

group :production do
  gem 'pg'
  gem 'thin'
end

group :development, :test do
  gem 'mysql2'
end

このようにして、1 つのデータベースを開発用 ( mysql) に使用し、別のデータベース ( pg) を本番用に定義します。

gemfile を変更した後:

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)'。これにより、すべてのアクションがgetリクエストを通じて利用可能になります。ただし、私はそれを使用したことがなく、ルートに問題がある可能性があると思います。

を指していることを確認するためにaccess/attempt_login、次によって生成されたルートを含めてください。

rake routes
于 2012-06-27T21:11:56.880 に答える