Ruby on Rails 1.2.1 リリース
Ruby on Rails Weblog - Rails 1.2: REST admiration, HTTP lovefest, and UTF-8 celebrations
川o・-・)<2nd life - Rails 1.2.1 リリース (あと htmlhelp 更新)
Ruby on Rails 1.2.1 と prototype.js 1.5.0 がリリースされた。Prototype.js はオフィシャルAPIドキュメントが公開された。
本家ブログの 1.2 でかかれている変更点を、つたない英語力で解読したので簡単にまとめとく。間違いがあったら指摘して下さい。
REST と リソース
- REST 風味を追加。
- リソース指向アーキテクチャ
Format と respond_to
- デフォルトのパスが ':controler/:action/:id.:format' に
- respond_to を使うと、:format 毎の応答を簡単に作成できる
class WeblogController < ActionController::Base def index @posts = Post.find :all respond_to do |format| format.html format.xml { render :xml => @posts.to_xml } format.rss { render :action => "feed.rxml" } end end end GET /weblog # returns HTML from browser Accept header GET /weblog.xml # returns the XML GET /weblog.rss # returns the RSS
マルチバイト
- UTF-8 がデフォルトに。KCODE は UTF-8にセットされる。
- TextHelper の truncate/excerpt, String の at/from/to/first/last でマルチバイトを意識したコードになった。
# 従来 '€2.99'.first # => '\342' truncate('€2.99', 2) # => '?' # Rails 1.2 '€2.99'.first # => '€' truncate('€2.99', 2) # => '€2'
Routes
- Action Pack の Route に関連する個所をすべて再実装。
- セミコロンやピリオドがセパレータとして認識される。
- /download/:file は :requirements => { :file => /.*/ } と変更する必要あり。
Auto-loading
- auto-load のバグを修正。
Prototype
- prototype.js 1.5.0 の採用。
- Element#show/toggle/hide, Field#clear/present を使ってる個所は変更する事。
// 従来 Element.show('page', 'sidebar', 'content'); // Rails 1.2 ['page', 'sidebar', 'content'].each(Element.show);
ActionMailer
- MIME バージョンのデフォルトを 1.0 に変更。