rake db:migrate

データベースを更新する

rake db:migrate

データベースを1つ前のスキーマに戻す

rake db:rollback

テスト環境のデータベースを更新する・巻き戻す

rake db:migrate RAILS_ENV=test
rake db:rollback RAILS_ENV=test

git でブランチを削除する

通常は-dオプションで削除します。他のブランチにマージされていない内容がある場合は-Dオプションをつけることで強引に削除できますが、そのブランチで行ったコミット内容は完全に削除されていまうので注意が必要です。

git branch -d ブランチ名
git branch -D ブランチ名

HerokuのPush先を変更する

Herokuで開発環境と運用環境の2つを構築していて、Production環境に接続する必要が発生したのでPush先を切り替えました。

まずは、接続先の確認。

[ec2-user@xxx]$ git remote -v
heroku  [email protected]:afternoon-coast-xxxx.git (fetch)
heroku  [email protected]:afternoon-coast-xxxx.git (push)
origin  https://github.com/ynishi2014/xxx.git (fetch)
origin  https://github.com/ynishi2014/xxx.git (push)

herokuの接続先を変えれば良いですね。

[ec2-user@xxx]$ git remote set-url heroku [email protected]:play-study.git

接続先が変わったか確認します。

[ec2-user@xxx]$ git remote -v
heroku  [email protected]:play-study.git (fetch)
heroku  [email protected]:play-study.git (push)
origin  https://github.com/ynishi2014/xxx.git (fetch)
origin  https://github.com/ynishi2014/xxx.git (push)

RubyからAmazon SESを使ってE-mailを送信

git clone git://github.com/aws/aws-sdk-ruby な感じで、SDKをAmazonAWSのSDKを取得した後、mail.rbに以下のコードを記述して、コマンドラインで「ruby mail.rb」を実行したところ、RubyからAmazonSES経由でメールを送信できました。
—-
# -*- encoding: utf-8 -*-
require ‘rubygems’
require ‘aws-sdk’
require ‘nkf’

ses = AWS::SimpleEmailService.new(
:access_key_id => ‘貴方のキーを入れてね’,
:secret_access_key => ‘貴方のアクセスキーを入れてね’)

#ISO-2022-jp
body_text = NKF.nkf(‘-jw’,’本文Test’)
subject = NKF.nkf(‘-Mw’, ‘タイトルTest’)

ses.send_email(
:subject => subject,
:to => ‘送信先のURLを入れてね’,
:from => ‘送信元のURLを入れてね(事前認証したE-mailアドレスからしか送信できません)’,
:body_text => body_text,
:body_text_charset => ‘ISO-2022-JP’
)

参考: RubyからAmazon SESでメールを送る

gemでawsのsdkをインストールする。

C:\Users\realbasic>gem install aws-sdk
Fetching: uuidtools-2.1.4.gem (100%)
Fetching: mini_portile-0.5.2.gem (100%)
Fetching: nokogiri-1.6.1-x86-mingw32.gem (100%)
Fetching: aws-sdk-1.33.0.gem (100%)
Successfully installed uuidtools-2.1.4
Successfully installed mini_portile-0.5.2
Successfully installed nokogiri-1.6.1-x86-mingw32
Successfully installed aws-sdk-1.33.0
4 gems installed
Installing ri documentation for uuidtools-2.1.4…
Installing ri documentation for mini_portile-0.5.2…
Installing ri documentation for nokogiri-1.6.1-x86-mingw32…
Installing ri documentation for aws-sdk-1.33.0…
Installing RDoc documentation for uuidtools-2.1.4…
Installing RDoc documentation for mini_portile-0.5.2…
Installing RDoc documentation for nokogiri-1.6.1-x86-mingw32…
Installing RDoc documentation for aws-sdk-1.33.0…