$ heroku rake db:migrate
について、何が問題だったのかが不明だったので、少し探りを入れてみた。
新しいプロジェクト(単位が違う?)を作って、今までの作業を試してみた。
具体的には、
$ rails new ruby_test
$ git init
$ git add .
$ git commit -m "Init"
としておいて、
$ heroku create でアプリケーションを作っておいて
$ git push heroku master
でherokuに送信。
まぁ、ここまでは単純なので、簡単に動きましたが、ここから
$ rake db:migrate
$ rm public/index.html
ってしてから、
config/routes.rbに、以下を追記。
root :to => "products#index"
ここまでで、
$ rails s
ってやると、動作確認OK!
だけど、
$ git add .
$ git rm public/index.html
$ git commit -m "Scaffold products"
$ git push heroku master
ってからの
$ heroku rake db:migrate
で、またつまづきました。orz
でも、過去の経験を活かし、
$ gem install pg
をしてから、Gemfileに以下を追加
group :production do
をしてから、Gemfileに以下を追加
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
ちなみに、元々記述してあった
gem 'sqlite3'
は削除しました。
んで、
$ git add .
をして
$ git commit -m "Scaffold products"
[master 1a0d0ed] Scaffold products
Committer: <Myname> <<MyPCname>@<MyAccount>.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 files changed, 6 insertions(+), 1 deletions(-)
# On branch master
nothing to commit (working directory clean)
うん、ちゃんと動いていない。
取りあえず、よくわからないので、
$ gem install postgres
をしてみるが、意味なさそう。。。
んで、次は、
sudo gem install pg -- --with-pg-dir=/opt/local/lib/postgresql90
をしてみる。これでもダメ。
よーわからんが、取りあえず
git push heroku master
で、マスターに送信!
$ git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 369 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
To git@heroku.com:<MyAppName>.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:<MyAppName>.git'
うん、何か失敗しとるぞ。どれどれ。。。
pg追加しろとか書いてあるぞ。。。
でも、追加したんですけど。。。
よくよく見ると、
$ git commit -m "test"
でうまくコミットできてない。orz
あ、そういえば、Bundler入れてないなー。
ということで、
gem install bundler
してみるもダメ。
でも、
$ bundle install --without production
をしてみて
$ git commit -a
でコミットして、
$ git push heroku master
したら、うまくコミットできたよ!
そして、問題の
heroku rake db:migrate
もうまくいったよ!
問題の原因がわかったよ。
原因は確かにpgが入っていない事だったんだけど、
それをちゃんとherokuにコミットできていなかったんだね。。。orz
取りあえず、すっきりしたので、次回からは次のステップへ!って同じ事書いてる?www
あ、でも気になる事を1つだけ。
今から作るアプリ、postgresql使う予定なんだけど、sqlite3とか言ってるよ。。。
あ、でも気になる事を1つだけ。
今から作るアプリ、postgresql使う予定なんだけど、sqlite3とか言ってるよ。。。
0 件のコメント:
コメントを投稿