ラベル Ruby の投稿を表示しています。 すべての投稿を表示
ラベル Ruby の投稿を表示しています。 すべての投稿を表示

MacでRubyにいきなり挫折しかけた件

puts "Hello,World!"
print "Mac OSXのテキストエディットだとエラーが出たよ。\n"
print "いきなり挫折しそうになった。\n"
print "Rubyのバージョン(2.3.1)が問題かと思って、バージョンを変えてみてもダメだった。\n"
print "エディタが原因だったらしく、Atomというエディタに変えたらエラーがとれた。\n"
puts "Hello,World! で挫折したら、泣けるよな。”
print "たぶん、文字コードか、改行コードが問題だったのだろう。\n”

hello.rbで保存

> ruby hello.rb

Hello,World!
Mac OSXのテキストエディットだとエラーが出たよ。
いきなり挫折しそうになった。
Rubyのバージョン(2.3.1)が問題かと思って、バージョンを変えてみてもダメだった。
エディタが原因だったらしく、Atomというエディタに変えたらエラーがとれた。
Hello,World! で挫折したら、泣けるよな。
たぶん、文字コードか、改行コードが問題だったのだろう。

Windows7でコマンドマクロを使う場合。

Windows7にRubyをインストールして、WEBrickを起動する場合、ちょっと面倒。
コマンドプロンプトで下記を入力して起動する。

> ruby -run -e httpd -- --port 3000 .

いやいやいやいや、毎回これを入力するのはめんどくさすぎ!!

で、doskeyマクロを使って、コマンドマクロ(別名エイリアス)を設定すると楽になる。
設定方法は、こんな感じ。

> doskey マクロ名=コマンド

今回はWEBrickというマクロ名を設定してみた。

> doskey webrick=ruby -run -e httpd -- --port 3000 .

これで、

> webrick

とマクロ名をタイプするだけで、WEBrickが起動する。

ちなみに、どんなコマンドマクロが登録されているか調べたいとき。

> doskey /macros

コマンドマクロを削除したい場合。

> doskey マクロ名=

空のコマンドを登録するとコマンドマクロは削除される。

コマンドマクロはコマンドプロンプトを終了してしまうと消えてしまう。
それを防ぐためには、次のようにコマンドマクロを保存しておくと良い。

> doskey /macros > macros.bat

で、コマンドプロンプトのアイコンを右クリックしてプロパティを出す。
で、リンク先に次のように記載する。

%windir%¥system32¥cmd.exe /k macros.bat

これで、このアイコン経由で起動したコマンドプロンプトではコマンドマクロが設定された状態で立ち上がる。

Ruby2.1.1 + Rails4.1.0 + MySQL5.6.17 でScaffoldしてみた。

なんか躓いて、一晩泣くハメになった。
今日、お昼頃に成功したんで「やったー!」と叫びました。
備忘録として作業メモを作っておきましょう。

MySQLはユーザアカウントの管理がキビしいので、まず、インストール済みのMySQLに作業用アカウントをつくることから始めてみた。

MySQLにはrootアカウントで入って、こんな感じで作業用カウントを作ってみた。

mysql > GRANT ALL ON *.* TO 'hogehoge'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

意味的には、'password'というパスワードで'localhost'から接続する'hogehoge'というユーザに管理者権限をつけるという感じ。ここら辺はちゃんと権限管理をすべきなんだろうけれど、いまは先を急ぐのでこれで行くよ。''は必要なので書き落とさないように注意。

じゃ、まずはRailsアプリを新規作成。
データベースはMySQLを指定。

[hogehoge@centos ~]$ rails new rails_app --database=mysql
      create 
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.1
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.3
Using thread_safe 0.3.3
Using tzinfo 1.1.0
Using activesupport 4.1.0
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.0
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.0
Using activemodel 4.1.0
Using arel 5.0.1.20140414130214
Using activerecord 4.1.0
Using bundler 1.6.2
Using coffee-script-source 1.7.0
Using execjs 2.0.2
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.0
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.9.2
Using jbuilder 2.0.6
Using jquery-rails 3.1.0
Using mysql2 0.3.15
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.0
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.2
Using turbolinks 2.2.2
Using uglifier 2.5.0
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted

で、rails_app内のGemfileを編集する。

[hogehoge@centos ~]$ cd rails_app
[hogehoge@centos ~]$ vi Gemfile

で、Gemfileを開き、これ(↓)のコメントアウトを外す(#を取り除く)
gem 'therubyracer',  platforms: :ruby

で、再度コメントアウトしたファイルをbundleインストールする。

[hogehoge@centos rails_app]$ bundle install
Resolving dependencies...
Using rake 10.3.1
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.3
Using thread_safe 0.3.3
Using tzinfo 1.1.0
Using activesupport 4.1.0
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.0
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.0
Using activemodel 4.1.0
Using arel 5.0.1.20140414130214
Using activerecord 4.1.0
Using bundler 1.6.2
Using coffee-script-source 1.7.0
Using execjs 2.0.2
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.0
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.9.2
Using jbuilder 2.0.6
Using jquery-rails 3.1.0
Using libv8 3.16.14.3
Using mysql2 0.3.15
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.0
Using rdoc 4.1.1
Using ref 1.0.5
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.2
Using therubyracer 0.12.1
Using turbolinks 2.2.2
Using uglifier 2.5.0
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

無駄なインストールが続いているような気がするけれど、therubyracer 0.12.1 が追加インストールされた。

じゃ、scaffoldの準備に取りかかりますか。

[hogehoge@centos rails_app]$ rails g scaffold Ranking name:string score:integer
      invoke  active_record
      create    db/migrate/20140420023921_create_rankings.rb
      create    app/models/ranking.rb
      invoke    test_unit
      create      test/models/ranking_test.rb
      create      test/fixtures/rankings.yml
      invoke  resource_route
       route    resources :rankings
      invoke  scaffold_controller
      create    app/controllers/rankings_controller.rb
      invoke    erb
      create      app/views/rankings
      create      app/views/rankings/index.html.erb
      create      app/views/rankings/edit.html.erb
      create      app/views/rankings/show.html.erb
      create      app/views/rankings/new.html.erb
      create      app/views/rankings/_form.html.erb
      invoke    test_unit
      create      test/controllers/rankings_controller_test.rb
      invoke    helper
      create      app/helpers/rankings_helper.rb
      invoke      test_unit
      create        test/helpers/rankings_helper_test.rb
      invoke    jbuilder
      create      app/views/rankings/index.json.jbuilder
      create      app/views/rankings/show.json.jbuilder
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/rankings.js.coffee
      invoke    scss
      create      app/assets/stylesheets/rankings.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

で、Ruby on Railsのモデルファイルが作成されたら、(この場合rails_app内の)configフォルダ内にあるdatabase.ymlのファイル内容をMySQLと接続するために書き換える。

[hogehoge@centos rails_app]$ cd config
[hogehoge@centos config]$ vi database.yml

 default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password:
  socket: /var/lib/mysql/mysql.sock

となっているのをこんな感じに変更。

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: hogehoge
  password: password
  host: localhost
  socket: /var/lib/mysql/mysql.sock

hostの部分は、Rails ServerとMySQLサーバとの関係によって、Localhostだったり、特定のIPアドレスだったりするらしい。
configのディレクトリから一つ上に上がっておく。

[hogehoge@centos rails_app]$ rake db:create

問題がなければエラーを吐かずに、何事もなかったようにコマンド入力待ちになる。
データベースがMySQL上に作成されたはずなので、次にテーブルをデータベース内に作成する。

[hogehoge@centos rails_app]$ rake db:migrate
== 20140420055229 CreateRankings: migrating ===================================
-- create_table(:rankings)
   -> 0.0100s
== 20140420055229 CreateRankings: migrated (0.0101s) ==========================

これでテーブルも作られたらしい。
じゃあRails Serverを起動して結果を見てみよう。

[hogehoge@centos rails_app]$ rails server

Webブラウザを立ち上げて、アクセスしてみる。

※この時に、本当に気をつけて欲しいのは、URL表記のせいで、Routing Errorが出ても焦らないで欲しいということ。Railsのモデルを作成したとき、今回は確か「$ rails g scaffold Ranking name:string score:integer」としたので、モデル名はRankingと普通考えてしまう。だからWebブラウザでURLを「http://localhost:3000/ranking」とするとRouting Errorの表示が出るのでビックリする。
Railsの場合、モデル名は「複数形」になる(なってしまう?)ので、この場合のURLは「http://localhost:3000/rankings」と後ろにsをつけて複数形にすると、目的のページが表示されるはずだ。

こんな単純な落とし穴にハマって、昨夜から頭を抱えていたのがバカみたいだ。 (>_<)

Rails4.0でActionController::InvalidAuthenticityTokenでエラーになった場合

「Herokuではじめる Railsプログラミング入門」のサンプルでうまく動かなかった原因が分かったのでメモを残しておきます。P,160からの「フォームを送信しよう」を入力して動かしてみた。

最初の画面

で、エラー画面。

googleさまに対処方法を尋ねたら、Rails2.0よりCSRF(クロスサイトリクエストフォージェリ)対策が施されているため、エラーになってしまうのだとか。クロスサイトリクエストフォージェリとは「Webサイトにスクリプトや自動転送(HTTPリダイレクト)を仕込むことによって、閲覧者に意図せず別のWebサイト上で何らかの操作(掲示板への書き込みなど)を行わせる攻撃手法」だそうで、代表的なサイバー攻撃の一つだとか。

で。この対応策として、sample_controller.rbに次の一行(赤字のやつ)を書き足した。

====================================
#coding:utf-8

class SampleController < ApplicationController

skip_before_filter :verify_authenticity_token ,:only=>[:index2]

  def index2
    if request.post? then
        @msg = "you type: " + params[:text1]
    else
        @msg="なにか入力してください。"
    end
  end

end
====================================

で、再度実行してみると、無事にこちらの画面が出現。

「Herokuではじめる Railsプログラミング入門」のミスでもなんでもなくて、もともとRuby1.9.3とRails3の組み合わせで書かれているので問題が出ないのかもしれません。

Linuxのディレクトリやファイルのグループ変更はchgrpを使う。

さてと。
CentOS上のRuby on Railsにトラブルが起こっている。
一通りインストールを終えた後、テスト用のプロジェクトを作ってみようとするとエラーが発生。

========================================
[rails@centos ~]$ rails new testrails
      create 
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:89:in `run': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)

    /usr/local/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for rb_integer_pack()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
/usr/local/lib/ruby/2.1.0/mkmf.rb:2189:in `initialize': Permission denied @ rb_sysopen - Makefile (Errno::EACCES)
    from /usr/local/lib/ruby/2.1.0/mkmf.rb:2189:in `open'
    from /usr/local/lib/ruby/2.1.0/mkmf.rb:2189:in `create_makefile'
    from extconf.rb:55:in `


'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/sqlite3-1.3.9/gem_make.out
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:38:in `block in build'
    from /usr/local/lib/ruby/2.1.0/tempfile.rb:324:in `open'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:17:in `build'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:160:in `chdir'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:160:in `block in build_extension'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:159:in `synchronize'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:159:in `build_extension'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:924:in `each'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:924:in `find'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems.rb:185:in `try_activate'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendor/net/http/persistent.rb:12:in `'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendored_persistent.rb:3:in `'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/fetcher.rb:1:in `'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/cli/install.rb:68:in `run'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/cli.rb:146:in `install'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendor/thor/command.rb:27:in `run'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendor/thor.rb:363:in `dispatch'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/vendor/thor/base.rb:440:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/cli.rb:9:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/bin/bundle:20:in `block in
'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.6.0.rc2/bin/bundle:20:in `
'
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
[rails@centos ~]$
========================================

なんとなく吐き出されたメッセージを見ていると、bundle install以降にトラブルが発生していて、それも/usr/local/lib/ruby 以下のアクセス権に問題が発生している模様。
ディレクトリ、ファイルはインストール時に所有者がrootになっているのは仕方ないとして、利用者グループを変更することで、この問題を解決したい。

もともとrailsでいろいろ実験するアカウントは、railsというグループに所属させていた。だからこのグループが/usr/local/lib/ruby/以下のすべてのファイル、ディレクトリに対し「読み書き」ができるようにしてあげれば良いのではないかと。

所有者がrootなので、suコマンドなどで一時的にrootになり、/usr/local/lib/の位置でrubyディレクトリに対し次のコマンドを叩くと良い。

chgrp -R rails ruby
(意味は、rubyのディレクトリとその中身のグループを全部railsに変更する)
これで、rubyディレクトリの中身すべてのグループがrailsになる。

それからrubyディレクトリに対し、railsグループが読み書き実行できるようにアクセス権の変更を行う。
chmod -R g+rwx ruby

あらためて rails new testrails を叩くと、問題なく終了するはず。

はぁ、それにしてもUnix系のOSは、アクセス権の設定でつまづくことが多いような気がする。
Windowsのお気楽なアクセス権設定とは雲泥の差だわ。

Railsの新規プロジェクトを作成するときは

だいたいいつも忘れてしまっているので、備忘録代わりに。
この原稿を書いているときにテキストエディタがハングして全部パーになったので、ちょっとイラッとしながら再度書き直そう。

Railsのプロジェクトを新規作成するのは、現在Aptana Studio3のGUIからは不可能になっているみたいだ。だからターミナルを立ち上げるか、あるいはAptana Studio3内のターミナルでユーティリティスクリプトを叩く。いずれにしてもターミナルを立ち上げる。

Railsのプロジェクトを作成するディレクトリへ移動して、このコマンドを叩く。

rails new プロジェクト名

すると、大体こんな風に進行する。
途中でパスワードの入力が求められる。
(つまりsudoコマンドが使える状態になっているということ)

$ rails new myapp
      create 
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install


Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:

    bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.

Password:
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.1.1
Using i18n 0.6.9
Using minitest 4.7.5
Installing multi_json 1.9.0
Using atomic 1.1.15
Using thread_safe 0.2.0
Using tzinfo 0.3.38
Using activesupport 4.0.3
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.3
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.3
Using activemodel 4.0.3
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.3
Using bundler 1.6.0.rc
Using coffee-script-source 1.7.0
Using execjs 2.0.2
Using coffee-script 2.2.0
Using thor 0.18.1
Using railties 4.0.3
Using coffee-rails 4.0.1
Using hike 1.2.3
Using jbuilder 1.5.3
Using jquery-rails 3.1.0
Using json 1.8.1
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.0.1
Using rails 4.0.3
Using rdoc 4.1.1
Using sass 3.2.14
Using sass-rails 4.0.1
Using sdoc 0.4.0
Using sqlite3 1.3.9
Using turbolinks 2.2.1
Using uglifier 2.4.0
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
$

で、新規プロジェクトが出来上がっているはず。

CentOSにAptana Studio3をインストールしてみた。

CentOSでRuby on Railsをごちゃごちゃいじるために、IDEはやっぱり必要。
Eclipseにプラグインの形で構築しようと試みたんだけど、どうしてもエラーが出てしまう。
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]みたいなヤツで、情報も少なく対処方法も正直よくわからない。

だったらプラグイン形式をやめて、スタンドアローンアプリとしてインストールして解決することにした。その備忘録を残しておこうか。

1.Aptana Studio3をサイトからダウンロードする。
2.ダウンロードしたzipファイルを解凍する。
 今回は自分のホームディレクトリに解凍して置くことにした。

 unzip Aptana_Studio_3_Setup_Linux_x86_64_3.4.2.zip

3.必要ならば日本語化ファイルも入手しておく。
 これはEclipse日本語化と同じ作業をやれば良いので、ここでは割愛。
4.Aptana Studio3が起動するか確認してみる。
 Aptana Studio3のディレクトリに移動する。

 cd Aptana_Studio_3
 ./AptanaStudio3 -clean

5.シェルを作って起動できるようにする。
 ※正直Linuxのシェルとか良くわからないで書いているので、あくまで参考までに。

 #!/bin/sh
 cd /home/ユーザー名(=ホームディレクトリ名)/Aptana_Studio_3
 ./AptanaStudio3

 これをaptana.shというファイル名で保存。
 パーミッションを変更する。GUI上でファイルのプロパティを「プログラムとして実行できる」というチェックボックスにチェックを入れておく。

 さらに/usr/local/bin/に移動させる。

 su
 cp aptana.sh /usr/local/bin/

6.パネルから起動できるようにする。
 上部にあるだろうGNOMEパネル上で右クリック→パネルへ追加→カスタム・アプリケーションのランチャー→追加ボタンを押す。
 種類:アプリケーション
 名前:適当な名称を入力
 コマンド:/usr/local/bin/aptana
 コメント:適当に何か入力してもしなくても。
 あと、アイコンをクリックして、Aptana_Studio_3のディレクトリ内のicon.xpmを指定する。

 OKボタンをクリックして作業終了。
 以降は、パネル上のアイコンをクリックすることでAptana Studio 3を起動できる。

VMware Fusion上のRuby on Railに外部からアクセスしたい!

今週末は10年に一度の大雪の朝。
早起きして、1時間かけて自宅前を雪かきしたら、汗をびっしょりかきました。
腕とかは全然問題ないけれど、長時間中腰でシャベルを操っていると腰が痛くて。。。。

は、さておき。

なんか、ネットでごちゃごちゃやってて楽しい、あるいはネットっておもしろいぞって感じるためには、やっぱりローカルコンピュータにサーバ立てて遊んでいるんじゃ分からないんですね。

先日MacBook ProにVMware Fusionをインストールして、ゲストOSにCentOSを立ち上げてみたことは既報の通り。そこにRuby on Railをインストールして、http://Localhost:3000 でRailsサーバが立ち上がっていることを確認しバンザーイ \(^_^)/ と喜んでました。

でもまあ、Localhostを叩いても、なんかつまらないというか、別にねぇ。
「ネット越し」ってヤツをちゃんと体験したくて。

ちょっとgoogle先生に尋ねると、要はCentOSのファイアウォールのポートを開ける作業をやれと言うことなんだそうだ。

まず、VMware側で、設定ネットワーク設定が必要になります。
「仮想マシン」→「設定」→「ネットワークアダプタ」で、デフォルトでは「インターネット共有 Macを共有」になっている設定を、「ブリッジされたネットワーキング 自動検出」に切り替える。

で、いよいよCentOS側ファイアウォールの設定を変更。
ちゃんとやるには iptables を使って、設定ファイルを書き換えれば良いのだけれど、あまりよく分かっていないレベルの人にはCentOSのツールを使って設定してあげれば良い。「システム」→「管理」→「ファイアウォール」で、必要なサービスにチェックを入れてあげる。「信頼したサービス」でWWW(HTTP) 80/tcp にチェックを入れた。これでapache を起動しておくとアクセスに対して反応がある。

Ruby on Rails も外から叩きたいので、「その他のポート」で、3000ポートを開けてあげる。

それからVMware Fusion上で稼働しているCentOSのIPアドレスを知る必要がある。

ifconfig

で表示された inet addr:xxx.xxx.xxx.xxx (xxxは数字)がCentOSに割り当てられたIPアドレス。この情報をもとにMac osX側、あるいは別のマシンのブラウザからアクセスし、希望していた表示が現れたら成功!

apacheの起動だけ確認したければ、http://xxx.xxx.xxx.xxx (CentOSのIPアドレス)。
Ruby on Railの起動を確認したければ、CentOS側でRails Serverを起動しておいてから、外部のマシンからブラウザで http://xxx.xxx.xxx.xxx:3000/ にアクセスしてみる。

念のため、apacheの起動の仕方。
CentOSのターミナルで、下記コマンドを叩いておく。

service httpd start

サーバから反応があると、なんとなくネットワークをいじくってる楽しみがわいてくるような気がしませんか???

CentOSにRuby on Railsをインストールしたメモ

今日は午後、神保町に外出していた。
来場者が詰めかけている広い講堂には、TVでしか見たことのない有名政治家の挨拶があったり、官房長官のビデオメッセージがあったりと、なかなか賑々しかった。
途中、急に空気が埃っぽく感じるようになった。咳が止まらなくなって、なんだろう、風邪に匂いがあるとしたら、体育倉庫の隅に放置されたマットレスのような感じのアレだ。
いや、ひょっとしたら、これは花粉症の前触れかも。

で、忘れないうちにCentOSにRuby on Railsをインストールした手順を記録しておこう。
先人の皆様の努力に感謝しつつ。

インストールを開始するにあたって、rootでログオンするか、あるいは自分のアカウントをrootと同じ権限を与えておく必要がある。

まず、gcc、yaml、zlibのインストールからスタート。

yum -y install gcc
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar zxvf yaml-0.1.4.tar.gz
cd yaml-0.1.4
 ./configure
make
make install

yum -y install zlib-devel

次にRubyをインストール。
Rubyにはいろいろとバージョンがあるので、確認をしておくと良い。
ftp://ftp.ruby-lang.org/pub/ruby/ にアクセスすると、各種バージョンを発見。
昨日現在の安定版は2.1.0だそうなので、次のように指定した。

wget ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
tar zxvf ruby-2.1.0.tar.gz
cd ruby-2.1.0
./configure
make
make install
cd ..

ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-Linux]

で、ちゃんとインストールされていることを確認。

次はGemをアップデートする。
gem install rubygems-update

最近方法が変わったらしい。
gem本体のアップデートをまずやってみる。
update_rubygems
次にgemにインストールされている全パッケージをアップデートする。
gem update

gemのバージョンを確認するにはこちら。

gem -v
2.2.1

いよいよRailsのインストール。
gem install rdoc
gem install rails
ここからしばらくマシンが固まったように見えるけど、気にせずのんびり待つこと。
Railsのバージョンを確認。

rails -v
Rails 4.0.2

で、Ruby On Railsのインストールは成功したっぽい。
データベースのインストールは別途必要かと思う。

もう一つ、JavaScriptのランタイムをインストールしておく。
http://nodejs.org/dist/latest/ にアクセスして、最新版を確認する。

wget http://nodejs.org/dist/latest/node-v0.10.25.tar.gz
tar xzvf node-v0.10.25.tar.gz
cd node-v0.10.25
./configure
make
make install
cd ..

では、ホームディレクトリ上でテストを実行してみる。
rails new testrails
cd testrails
rails server

これでRailsサーバが起動する。
ブラウザを立ち上げ、http://localhost:3000 にアクセスし、Railsサーバが立ち上がっているか確認できればOK!

Railsサーバを停止するには、Control+C 。
ちなみに、間違ってControl+Zを押してしまうと、Railsサーバがすでに起動中と表示されて、にっちもさっちもいかなくなる場合がある。そのときは次のように対応する。

fg
そのあとControl+CでRails Setrverをシャットダウンする。

まずはここまで。

Aptana Studio 3でRubyが使えるようになるまで。


とりあえず、いろいろと格闘した。
※すまん、まだ未完成。

Aptana Studio 3をインストールする前に、こんな環境を構築しておいた。

MITAKALABさんの「Macをはじめよう」(http://developer.mitakalab.com/mac)を参考にさせてもらって、こんな状況に。知識がないので、とりあえず素直に言われたとおりにしてみた。

1.XcodeとCommand Line Toolsのインストール
> appストアからXcodeをダウンロードしてインストール
> 次にXcodeを立ち上げて、Preferences > DownloadsからCommand Line Toolsをインストールする。

2.Homebrewをインストールする
> ターミナルを起動して、つぎのコマンドを入力。
> ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

3.Gitをインストールする
> ターミナルを起動して、次のコマンドを入力。
> brew install git

4.Oh-my-zshをインストールする
> ターミナルを起動して、次のコマンドを入力。
> curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

5.EmacsとSublineTextのインストール
Aptana Studio 3 を利用する人はスキップすればよいと思う。

6.Rubyのインストール
Rubyのバージョンを確認する。
> ターミナルを起動して、次のコマンドを入力。
> ruby -v
たぶん、ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0] と表示されるだろうと思われる。

Homebrewで最新版をインストールすると古いバージョンが上書きされてしまう。それを避けるため、rbenvをインストールして、複数のバージョンを切り替えられるようにする(※このためにAptana Studio 3での設定が難しくなった気がする)。

> ターミナルを起動して、次のコマンドを入力。
> brew install rbenv

> rbenvの設定をShellに追加するため、ターミナルを起動して、次のコマンドを入力。
> echo 'eval "$(rbenv init -)"' >> ~/.zshrc
> source ~/.zshrc

rbenvはRubyのバージョン管理を行うだけのツールのため、新バージョンのRubyをインストールするためのビルドツールをインストールする。
> ターミナルを起動して、次のコマンドを入力。
> brew install ruby-build

rbenvでRubyをインストールするために必要なrbenv-vars、openssl、readlineをそれぞれインストール。

> ターミナルを起動して、次のコマンドを入力。
> brew install rbenv-vars openssl readline

rbenvを使って、Rubyをインストール。
> ターミナルを起動して、次のコマンドを入力。
> rbenv install -l

これでインストール可能なバージョンが表示される。
例えば最新版を入力するためには、次のコマンドを入力する。

> rbenv install 1.9.3-p448
> rbenv global 1.9.3-p448
> rbenv rehash

これでRubyのインストールは完了。

7.Ruby on Railsのインストール
> ターミナルを起動して、次のコマンドを入力。
> sudo gem install rails --no-ri --no-rdoc


8.Aptana Studio 3 をインストールする
Aptanaのダウンロードページ(http://www.aptana.com/products/studio3/download)からアプリをダウンロードする。僕はStandalone Versionを選択した。普通にインストール作業を進める。

9.Apatana Studio 3 を日本語化する
Pleiades - Eclipse プラグイン日本語化プラグインページ(http://mergedoc.sourceforge.jp)の本体ダウンロード「最新版」か「安定版」ダウンロードする。zipファイルを解凍して、「features」と「plugins」フォルダの内容を、Aptana Studio 3の同じフォルダにコピーする。
Aptana Studio 3のフォルダ内にある設定ファイル AptanaStudio3.ini をテキストエディタで開き、最終行に次の一行を追加して保存。
-javaagent:plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar


10.Aptana Studio 3 でRubyインタプリターが使えるようにする方法
「Rubyの開発環境AptanaStudio3でUnable to find a Ruby executable が出る時の対処」(http://sakamoto-san.com/ruby_aptana_install.html)を参考にさせてもらいながら対応。ただし、こちらのページはWindowsベースの解説らしいので、Macの対応にはちょっと苦労した。

新規ソフトウェアのインストールでRuby開発ツールをインストールする
> 1)ヘルプ- 新規ソフトウェアのインストール
> 2)使用可能なソフト・ウェアサイト のハイパーリンクをクリック
> 3)追加(A) ※もしかしたらチェックが外れているだけかもしれないので、チェックを付ける
> 名前(A):Eclipse Indigo Update Site
> ロケーション(L):http://download.eclipse.org/releases/indigo
> 4)再ロード(L) しばらく待つ
> 5)OK
> 6)作業対象(W)–すべての使用可能なサイト–
> フィルタ入力: Ruby と入力して Enter? しばらく待つ
>
> プログラミング言語- 動的言語ツールキット – Ruby 開発ツールが表示されるのでチェックを付ける
> ※ 2012/06/23現在 バージョン:3.0.0.v20110424-7Z–E_ekMYXO4k101442
> 7)次へ
> 8)動的言語ツールキット – Ruby開発ツールをクリックして選択
> 9)次へ (以下詳細忘れました)
> 10)インストールが終了したら、一度Aptanaを停止して、-clean 起動

Macの場合の-clean起動は、ディレクトリの表記がある意味驚天動地だった。
ターミナルを起動して、次のコマンドを入力。

/Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/AptanaStudio3 -clean

次にRubyインタプリタの設定を行う。
ここで設定を行わないと、Aptana Studio 3内でRubyを実行することができない。

Aptana Studio 3 - 環境設定- Ruby - インタープリター にアクセスする。
ここになんらかのRubyインタープリターが登録されていれば、たぶん問題なし。
僕の環境では何も登録されていなかったので、このままではAptana Studio 3 内でのRuby実行はできない。

「追加」ボタンをクリックする。
インタープリター・タイプは Generic Ruby でOK。
インタープリター実行可能ファイルがある場所を指定してやる。

それを知るために、ターミナルを起動して、次のコマンドを入力。

> Which ruby
> /Users/あなたのユーザーネームとか/.rbenv/shims/ruby

ここに目的のRubyがある。

Aptana Studio 3に戻って、ディレクトリを参照するウィンドーの上部の窓を「Macintosh HD」にして、「ユーザ」→「あなたのユーザーネームのディレクトリ」→「.rbenv」→「shims」→「ruby」を選択して「open」ボタンをクリックすると「インタープリターの追加」画面にインタープリター・システム・ライブラリーに自動的にファイルが集められる。あとは「OK」ボタンを押せば、Aptana Studio 3でRubyが実行できるようになる。

僕の環境では、これでAptana Studio 3上でRubyが実行できている。

※ここで、Aptana Studio 3のコンソール上で確認したところ、古いバージョンのRubyが現れていた。ターミナルでは最新バージョンになっているので、この問題は解決しないと。

Macのこと含めて知らないことが多すぎて、Aptana Studio 3でなぜRubyが実行できないのかわからなかった、Aptana Studio 3をクリーン起動させるときのディレクトリ指定の方法がわからなかった、Aptana Studio 3にRubyインタプリターを追加するに当たって、「そもそもRubyってどこにインストールされるのよ!?」がわからずに苦労した。

先人たちの業績に感謝するとともに、僕の追記が誰かのお役に立てますように。

第2回:Rubyの開発環境をセットアップする。

で、Ruby編第2回に突入。開発環境を整える。

Ruby自体はスクリプト言語なので、WindowsXPのコマンドプロンプトと、スクリプトを書くためのテキストエディタがあれば最低限の開発環境はできてしまいます。
しかしデバッグをしたり、いちいちCUIで動かしているのもめんどくさいので、統合開発環境をインストールしてしまいましょう。

Eclipsを使うというハイエンドな方法もあるらしいが、今回は"RDE"(Ruby Development Environment)を選択しました。RDEは下記のURLから入手します。
http://homepage2.nifty.com/sakazuki/rde/index.html

あとRubyのリファレンスマニュアルとHELPファイルをダウンロードしておきます。
http://elbereth-hp.hp.infoseek.co.jp/ruby.html

リファレンスマニュアルはさておき。
ダウンロードしたファイルをクリックすれば、インストールが始まります。
途中であらかじめインストール済みのruby.exeのPath情報が尋ねられるので、あらかじめチェックをしておくと良いです。僕の環境では下記のpathになります。

C:\Program Files\ruby-1.8\bin\Ruby.Exe

あとはそのまま何も考えることなく先へ進んでいけば、RDEのインストールは完了です。

ダウンロード後に実施すること。
1.リファレンスマニュアルの設置
2.RDEの基本的な設定(特に日本語化)

では作業に取りかかります。

1.リファレンスマニュアルの設置
あらかじめダウンロードした圧縮ファイルを解凍します。
僕はRDE内にフォルダを作って、そこに設置しました。

2.RDEの基本的な設定(特に日本語化)
RDEを起動すると、まず設定ダイアログが出ます。これ全部英語。
とりあえずSubmitボタンを押して、先に進みます。

問題となるのは、メニューの日本語化と、エディタ部分の文字化け解消です。

■文字化けの解消
1)Tool→Options→Code Window→Charsetの「Default Charset」を「default」から「sjis」に変更する。
2)Tool→EDitor Property→Show→Font の「courier new」を「MS ゴシック」に変更する。
3)Tool→Editor Property→Showで「Font」をクリックした時に出てくる画面の右下の「文字セット」を、「日本語」にする。

でOK。ほかに、

4)Tool→Options→Othersの「Default Font」は「MS Pゴシック」よりも「MS ゴシック」の方が良い。
5)Tool→Options→Code Window→Converterの「Converter.dll」の「japanese.dll」を確認する。

■メニューを日本語化
1) 「ツール(Tool)」→「設定(Rubys Setting)」→「外部設定ファイル(Config File)」の画面の「翻訳ファイル(TranslationFile?)」に「C:\Program Files\RDE\Translations\Japanese_1000.xml」を選択。

もう一つ

■ヘルプファイルの設定
1)「ツール(Tool)」→「設定(Rubys Setting)」→「Rubyヘルプのパス」の設定のところで、設置したリファレンスマニュアル&ヘルプを指定する。

以上で開発環境のセットアップは終了です!

第1回:Rubyをインストールする

さてと、Rubyをインストールしてプログラミングを楽しんでみようと思う。
Rubyの記事は当面外部公開しない予定で行きます。

Rubyをインストールした環境。
■OS:WindowsXP SP2
■CPU:Pentium-4 3.0GHz
■Memory:512Mbytes

Windows VISTAにはちょっと力不足という感じでしょうか。

まずRubyを始めるための基本環境を構築します。

1.Rubyのインストール
まず肝心のRuby本体をダウンロードしてきます。
各OS向けのRuby本体は、下記のURLから入手することができます。
http://www.ruby-lang.org/ja/

Windows向けにはいくつかのバイナリバージョンが存在してます。
い くつかのサイトで情報を漁ったところ、WindowsにはActiveScriptRubyが良いとRecomendされていたので、これを選択しまし た。この記事を書いている時点では、version1.8.5.2です。ActiveScriptRubyは下記のサイトで配布されています。
http://www.geocities.co.jp/SiliconValley-PaloAlto/9251/ruby/

ダウンロードしたファイルをダブルクリックすれば、あとは勝手にインストール作業が始まります。

デスクトップ上に"ruby console"というショートカットができます。
これをクリックすると分かりますが、Windowsアクセサリーのコマンドプロンプトが立ち上がるだけです。Rubyが機能しているかどうかテストします。コンソール画面で次のコマンドを打ちます。

>ruby.exe -v

正しくインストールされていれば、次のメッセージが返ってきます。

ruby 1.8.5 (2006-08-25) [i386-mswin32]

この表示が出れば、Rubyのインストールは成功です。