読者です 読者をやめる 読者になる 読者になる

Ruby-1.8.7とRails-1.2.x、Rails-2.0.xは使えない

Ruby Rails

Rubyの1.8.7を入れるとString#firstが動かないようです。
そのまま動く場合もあるのですが、プラグインなどで地雷を踏みます。
私もacts_as_attachmentが動きませんでした。

Ruby-1.8.6+Rails-1.2.xの場合

% ./script/runner 'p "aaaaa".first'
"a"

Ruby-1.8.6+Rails-2.0.xの場合

% ./script/runner 'p "aaaaa".first'
"a"

Ruby-1.8.7+Rails-1.2.xの場合

% ./script/runner 'p "aaaaa".first'
/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/runner.rb:47: undefined method `[]' for #<Enumerable::Enumerator:0x25c6fa0> (NoMethodError)
	from (eval):1
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `eval'
	from /opt/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/runner.rb:47
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from ./script/runner:3

Ruby-1.8.7+Rails-2.0.xの場合

% ./script/runner 'p "aaaaa".first'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/runner.rb:47: undefined method `[]' for #<Enumerable::Enumerator:0x1972164> (NoMethodError)
	from (eval):1
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `eval'
	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/runner.rb:47
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from ./script/runner:3

このように組み合わせの相性が悪いのがわかります。

ちなみにRuby-1.8.7+Rails-2.1.0の場合

% ./script/runner 'p "aaaaa".first'
"a"

問題ありません。Rails-2.1.0以降はRuby-1.8.7で問題なさそうです。