2013年1月2日水曜日

herokuでsqlite3からpostgresqlへ

sqlite3 -> postgresql にDBを変更する時のログ。

$ heroku rake db:migrate</ br> ! For Cedar apps, use: `heroku run rake db:migrate` $ heroku run rake db:migrate</ br> Running rake db:migrate attached to terminal... up, run.5672 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 at /app/Rakefile:9) 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 at /app/Rakefile:9) Connecting to database specified by DATABASE_URL Migrating to CreateMessages (20121222150925) == CreateMessages: migrating ================================================= -- create_table(:messages) NOTICE: CREATE TABLE will create implicit sequence "messages_id_seq" for serial column "messages.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "messages_pkey" for table "messages" -> 0.0589s == CreateMessages: migrated (0.0590s) ========================================

2013年1月1日火曜日

Gemfileを修正したらbundle install

しないと、以下の様なErrorが出て、herokuにpushできない。


git push heroku master
Counting objects: 91, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (81/81), done.
Writing objects: 100% (91/91), 30.37 KiB, done.
Total 91 (delta 5), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.0.pre.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
       You are trying to install in deployment mode after changing
       your Gemfile. Run `bundle install` elsewhere and add the
       updated Gemfile.lock to version control.
       You have added to the Gemfile:
       * sqlite3
       * thin
       * pg
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app

To git@heroku.com:xxxxxxxxxxxxxxxxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)

2012年12月25日火曜日

【Linux】CentOS6でuseraddしても、ログインできない

問題: タイトルどおり。
原因: ログインユーザがGroup指定されており、そこに新規Userを追加していなかった。
解決策: vi /etc/group で、対象のGroupに新規ユーザを追加する。

↓のサイトを見て解決。
http://koexuka.blogspot.jp/2009/08/ssh.html


他にもメモ。
以下、lockoutはユーザ名です。


password-authに以下の行を追加すると、パスワードを間違えた回数が記録される。
auth        required      pam_tally2.so deny=3

記録回数の確認は、以下のコマンド。
pam_tally2 -u lockout

ロックアウト解除
pam_tally2 -r -u lockout
or
pam_tally2 -u lockout --reset


ロックアウトをテストするために、ユーザ追加して、確認する手順。

useradd lockout ← ユーザの新規追加

tail -n 10 /var/log/secure ← ログインできない理由を調査

Dec 25 14:05:03 xxx sshd[32330]: User lockout from xxx.xxx.xxx.xxx not allowed because none of user's groups are listed in AllowGroups


vi /etc/group ← 所属Groupにlockoutユーザを追加


これで、ログイン可能!

2012年12月24日月曜日

rvmでRubyを管理するためのメモ。


  489  rvm list
  490  rvm use 1.9.3 --default
  491  rvm use 1.9.3-p125 --default
  493  rvm list
  494  rvm use 1.8.7-p357 --default
  496  rvm list
  497  rvm use 1.9.2-p290 --default
  637  rvm list

2012年12月9日日曜日

gitで公開されているプロジェクトをclone

特に難しい事は無いです。

git入れてる前提で。

cloneを作りたいフォルダで、というか、フォルダを私は以下に置いています。

~/workspace/rubyonrails/gitclone

で、gitcloneフォルダ以下で、以下のコマンドすればOK。

$git init
$git clone <Repository URL>

見た方がよいプロジェクトは以下のサイトにまとめて頂いている方がいますので、参考にして下さい。

http://bit.ly/UnQm3C

Ruby on Railsで新しいプロジェクトを作る時


mkdir -p の"-p"は中間フォルダも作成するオプション。
やることは、フォルダ作ってGemfile作ってbundle installするだけ。

$ mkdir -p ~/workspace/rubyonrails/herokusample
$ cd ~/workspace/rubyonrails/herokusample/
$ echo "source 'https://rubygems.org'" >> Gemfile
$ echo "gem 'rails', '= 3.2.5'" >> Gemfile
$ bundle install

これが終わったら、カレントディレクトリをherokusampleにして、

$ bundle exec rails new <app name> -T

とすれば、<app name>フォルダ以下にrailsに必要なファイル群が生成される。
ここで、scaffold作るもよし。

rubyのversionを整える。

久々にRubyを触りたくなったので、メモ。

まず、Rubyのversionを確認。
以下のコマンドで確認。

$ rvm list

rvm rubies

   ruby-1.8.7-p357 [ i686 ]
=* ruby-1.9.2-p290 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

ruby-1.9.3-p125を使いたかったので、以下のコマンドで使いたいversionのrubyを入れました。

$ rvm install 1.9.3-p125
Fetching yaml-0.1.4.tar.gz to /Users/<username>/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/<username>/.rvm/src
Configuring yaml in /Users/<username>/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/<username>/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/<username>/.rvm/usr
Installing Ruby from source to: /Users/<username>/.rvm/rubies/ruby-1.9.3-p125, this may take a while depending on your cpu(s)...

ruby-1.9.3-p125 - #fetching 
ruby-1.9.3-p125 - #downloading ruby-1.9.3-p125, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9505k  100 9505k    0     0   290k      0  0:00:32  0:00:32 --:--:--  202k
ruby-1.9.3-p125 - #extracting ruby-1.9.3-p125 to /Users/<username>/.rvm/src/ruby-1.9.3-p125
ruby-1.9.3-p125 - #extracted to /Users/<username>/.rvm/src/ruby-1.9.3-p125
ruby-1.9.3-p125 - #configuring 
ruby-1.9.3-p125 - #compiling 
ruby-1.9.3-p125 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.15 for ruby-1.9.3-p125 ...
Installation of rubygems completed successfully.
ruby-1.9.3-p125 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p125 - #importing default gemsets (/Users/<username>/.rvm/gemsets/)
Install of ruby-1.9.3-p125 - #complete 


そして、確認してみて、以下のような感じです。

$ rvm list

rvm rubies

   ruby-1.8.7-p357 [ i686 ]
=* ruby-1.9.2-p290 [ x86_64 ]
   ruby-1.9.3-p125 [ x86_64 ]

# => - current
# =* - current && default
#  * - default