rvm上で、rails 3.2.3を動かす。Ubuntu 11.04

rvmとruby 1.9.3をインストールする Ubuntu 11.04 - kaishitaeiichiの日記で、rvmの環境構築できたはずなので、さっそくrailsを使ってみる。

Getting Started with Rails — Ruby on Rails Guidesをやってみる。

rvmで、切り替える環境を作成して、選択する。

eiichi@ubuntu-desktop:~$ rvm 1.9.3
eiichi@ubuntu-desktop:~$ rvm gemset create rails-getting-started
'rails-getting-started' gemset created (/home/eiichi/.rvm/gems/ruby-1.9.3-p125@rails-getting-started).
eiichi@ubuntu-desktop:~/rails-projects$ rvm use 1.9.3@rails-getting-started
Using /home/eiichi/.rvm/gems/ruby-1.9.3-p125 with gemset rails-getting-started

チュートリアルどおり、railsのプロジェクト作成

eiichi@ubuntu-desktop:~/rails-projects$ rails new blog -d mysql
      create  
      create  README.rdoc
      create  Rakefile

....

Using uglifier (1.2.4) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

自分の環境では、MySQLは動作中。
config/database.ymlで、DB接続設定を自分の環境に合わせる。

とりあえず、データベースを作成

eiichi@ubuntu-desktop:~/rails-projects/blog$ rake db:create
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

あれ?、、、、Windows上で、JRubyで作業したときには、こんなエラーでなかったはず。JRuby + Rails 3 + MySQL (Windows) - kaishitaeiichiの日記

同じような目にあっているひとがいるらしい。
ruby on rails 3.1 - ExecJS and could not find a JavaScript runtime - Stack Overflow

Gemfileに以下を追加

gem 'execjs'
gem 'therubyracer'

Gemfileに追加したライブラリをインストール

bundle install

ふう、今度はエラーなしだ。

eiichi@ubuntu-desktop:~/rails-projects/blog$ rake db:create
eiichi@ubuntu-desktop:~/rails-projects/blog$ 

だいじょうぶだ。

eiichi@ubuntu-desktop:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.

....

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| blog_development   |
| blog_test          |
| mysite             |
| mysql              |
+--------------------+
5 rows in set (0.05 sec)
mysql> 

あとは、もう、だいじょうぶかなあ。

JRuby + Windowsでがんばってたが、これで、Ruby + Linuxで作業できるよ。