HerokuのSQLでは別名をつける際にasをつけないとエラーが出る。

ActiveRecord::StatementInvalid (PGError: ERROR: syntax error at or near "high_price"
2011-10-30T09:02:04+00:00 app[web.1]: LINE 1: SELECT MAX(high_price) high_price,created_on FROM "exchange...

Error: SELECT  MAX(high_price) high_price,created_on FROM "exchange
OK SELECT  MAX(high_price) as high_price,created_on FROM "exchange

herokuにデータをimport

sudo heroku db:push

Taps Load Error: no such file to load -- taps/operation
You may need to install or update the taps gem to use db commands.
On most systems this will be:

sudo gem install taps

checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite3-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).

sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
sudo gem install taps
sudo heroku db:push

文字を入力するように言われるでプロジェクト名を記入。

simple-xxx-3380

herokuコマンド


herokuにプロジェクト作成

sudo heroku create appname

herokuにプッシュ

git push git@heroku.com:xxxx-rain-4919.git master

herokuでmigrate

sudo heroku rake db:migrate

herokuでログを見る

heroku config:add LOG_LEVEL=DEBUG
sudo heroku logs --tail

herokuでrails console

sudo heroku console

herokuでメンテナンス中にする

heroku maintenance:on

Ubutuでrails3をPostgresQLで動かす

rake db:migrate

Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

Gemfileに追加

gem 'pg'
sudo vi /etc/postgresql/8.4/main/pg_hba.conf

以下の行を変更

#local   all         all                               ident
local   all         all                               password

rake db:migrate

なお、rails3.1にpostgreSQLの9.1は使用できませんでした。

Railsのテーブルにテストデータをinsertする。

/test/fixtures/table名.ymlを作成


# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html

one:
  opening_price: 9.99
  low_price: 9.99
  high_price: 9.99
  closing_price: 9.99
  average_price: 9.99
  currency_type: 1
  created_on: 2011-09-21

two:
  opening_price: 9.99
  low_price: 9.99
  high_price: 9.99
  closing_price: 9.99
  average_price: 9.99
  currency_type: 1
  created_on: 2011-09-21

rake db:fixtures:load


CSVの場合
/test/fixtures/table名.csvを作成
csvの一行目はテーブルのカラム名を入れましょう

rake db:fixtures:load FIXTURES=exchanges