ã®å訳ããã¦ãã¾ããéãè¨å¤§ãªã®ã§ã¨ããããååãã¨ã³ããªã¨ãã¦åãåºãã¾ãããåºæ¬çã«æ訳ã§é©å½ã«åé¤ãããä»ãå ããããã¦ãé¨åãããã¾ããããééãçè¦ã¤ããããé£çµ¡ããé¡ããã¾ãï¼ï¼
å¾ç·¨ã¯ä¸é±éå¾ãããã¾ã§ã«æ¸ãã¾ãã
(追è¨)
id:gom68ãããå
¨æã®å訳ãããã¦ããã®ã§ãå
¨æã®å訳ãè¦ããæ¹ã¯ãã¡ããåç
§ãã¦ãã ããã
Rails3 リリースノート全文和訳 (ただし適当) - うっかりプログラミング日誌
âãããã®ã§å¾ç·¨ã¯æ¥ãããããããã®ç« ã®æ·±æããå ã«ããããããã¾ããã¼
(追è¨)
å¾ç·¨æ¸ãã¾ãã
Rails 3.0 リリースノート和訳 - 後編 - おもしろWEBサービス開発日記
ã¾ããã
Rails3.0ã¯ã¾ã ãã¼ã¿çããã°ããããããããªãã®ã§è¦ã¤ãããこちらã«å ±åãã¦ãã空è»ã®æ ¸çå¼¾çºå°ã¢ããªã®ãããªæ£ç¢ºããæ±ããããã¢ããªãRails 3.0ã§ã¤ãã£ã¡ãã ãã§ãããã§ãããããããæ°ããã¢ããªãéçºããã®ãªãæããã«ä½¿ã£ã¦ã¿ã¦ãã
Rails 3 ãã¬ãªãªã¼ã¹ãã¼ã¿çãã¤ã³ã¹ãã¼ã«ããããã«ã¯ãä¸è¨ã®ããã«ã¾ãRailsãä¾åãã¦ããgemãrubygemsã§ã¤ã³ã¹ãã¼ã«ããå¿ è¦ãããã
# Use sudo if your setup requires it gem install tzinfo builder i18n memcache-client rack \ rake rack-test rack-mount erubis mail text-format \ thor bundler gem install rails --pre
1 Rails3ã¸ã®ã¢ããã°ã¬ã¼ã
ã¢ããã°ã¬ã¼ããããªãããã®åã«ãã¡ãã¨ãã¹ãã³ã¼ããæ¸ãã¨ããæ¹ãããããã¾ã2.3.5ã«ã¢ããã°ã¬ã¼ããã¦ããã¡ãã¨åããã¨ã確èªãã¦ãã3ã«ã¢ããã°ã¬ã¼ãããæ¹ããããã
1.1 Rails3ã¯Ruby1.8.7以ä¸ãå¿ è¦
Rails3ã¯Ruby1.8.7以ä¸ãå¿ è¦ãå ¬å¼çã«ã¯1.8.7ããåã®Rubyã¯ãµãã¼ããã¾ãããRails3.0ã¯1.9.2ã¨äºææ§ãããã
1.2 Rails Application object
åãããã»ã¹ä¸ã§è¤æ°ã®Railsã¢ããªãåããããã®åå°ã¨ãã¦ãRails3ã§ã¯Application objectã¨ããæ¦å¿µãå°å ¥ããããApplication objectã¯ä¸ã¤ã§å ¨ã¦ã®ã¢ããªã®è¨å®ãä¿æããconfig/environment.rbã®ãããªãã®ã ãã
ããããã®Railsã¢ããªã¯å¯¾å¿ããapplication objectãæã£ã¦ãªãã¨ãããªãããapplication objectã¯config/application.rbã§å®ç¾©ããã¦ããããæ¢åã®ã¢ããªãRails3ã«ã¢ããã°ã¬ã¼ããããªããconfig/application.rbã追å ãã¦é©åãªè¨å®ãconfig/environment.rbãã移åãããå¿ è¦ããããã
1.3 script/* 㯠script/railsã«ç§»è¡ãã
scriptãã£ã¬ã¯ããªã«ç½®ããã¦ããã¹ã¯ãªããã¯å ¨é¨script/railsã«ç§»è¡ããããã¹ã¯ãªããã³ãã³ããå®è¡ãããã¨ãã¯ãscript/railsãç´æ¥å®è¡ããã«railsã³ãã³ããå®è¡ãã¾ããããrailsã³ãã³ãã¯railsã®ã«ã¼ããã£ã¬ã¯ããªã§å¼ã³åºãããããæ¤ç¥ãã¦ã¹ã¯ãªãããå®è¡ãã¦ããããã
å®è¡ä¾
rails console # => ./script/console rails g scaffold post title:string # => ./script/generate scaffold post title:string
1.4 config.gem
config.gemã¡ã½ããã¯bundlerã¨Gemfileã«ç½®ãæãã£ããã詳ããã¯2.1ãåç §ã®ãã¨ã
1.5 Upgrade Process
ã¢ããã°ã¬ã¼ãã®ä¸é¨ãèªååãã¦ããããã©ã°ã¤ã³rails upgradeããããã
ãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ãã¦ã
rake rails:upgrade:check
ã¨ããã¨ã¢ããªããã§ãã¯ãã¦ãã¢ãããã¼ãããã®ã«å¿ è¦ãªæ å ±ã表示ãã¦ãããããããã«ã¢ããªã®config.gemãã¿ã¦Gemfileãä½ã£ã¦ãããããããã«routesãã¡ã¤ã«ãåãããã«ä»ã®ã¢ããªã®ãåèã«ãã¦ä½ã£ã¦ããããã
rails upgradeãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«ã¯ä¸è¨ã®ããã«ããã¨ã§ãããã
rails plugin install git://github.com/rails/rails_upgrade.git
å®è¡ä¾ã¯omgbloglol - rails-upgrade is now an official pluginãåèã«ãã¦ãã
Railsã®ã¢ããã°ã¬ã¼ãã«é¢ãã¦ãã£ã¨ããããå©ãã欲ãããã°IRCã«è©³ãã人ããããRuby on Rails: Talk | Google グループã¨ãããããã¨åããããªåé¡ãããããããããåé¡ã解決ããããã®çµé¨ãããã°ã«æ¸ãã¦ã¿ããªã§ç¥èãã·ã§ã¢ããããï¼
ããã«è©³ããæ
å ±ã¯ãã¡ã - The Path to Rails 3: Approaching the upgrade
2 Rails3.0ã¢ããªã®ä½ãæ¹
railsã®ãã¼ã¿çã®ã¤ã³ã¹ãã¼ã«æ¹æ³
gem install rails --prerelease rails myapp cd myapp
2.1 Vendoring Gems
ã¢ããªãå®è¡ããã®ã«å¿ è¦ãªgemã¯RAILS_ROOT/Gemfileã«è¨è¿°ããããGemfileã¯Bundlerã¨å¼ã°ãããã©ã°ã¤ã³ã§å¦çãããããBundlerã¯ä¾åé¢ä¿ã«ããgemãã¤ã³ã¹ãã¼ã«ãããã©ã°ã¤ã³ã§ãä¾åé¢ä¿ã«ããgemãå ¨ã¦ãã¼ã«ã«ã«ãã¦ã³ãã¼ããã¦ãã¢ããªãã·ã¹ãã ã®gemã«ä¾åããªãããã«ãããã¨ãã§ãããã
詳ããã¯ãã¡ã
2.2 EdgeãªRailsã使ãã«ã¯
Bundlerã¨Gemfileã®ãããã§ãã³ãã³ãä¸çºã§railsã¢ããªãç°¡åã«åçµã§ããããã«ãªã£ãããrake freezeã¯ãã使ããªããã
gitãªãã¸ããªããç´æ¥edge railsãæã£ã¦ãã¦freezeãããæã«ã¯ --edge ãã©ã°ãã¤ãã
rails myapp --edge
ãã¼ã«ã«ã«Railsã®ãªãã¸ããªããã§ãã¯ã¢ã¦ããããã®ããã£ã¦ããããrailsã¢ããªãçæãããå ´å㯠--dev ãã©ã°ãã¤ãã
ruby /path/to/rails/railties/bin/rails myapp --dev
3 Railsã®ã¢ã¼ããã¯ãã£çãªå¤æ´
Railsã¢ã¼ããã¯ãã£ã«é¢ãã6ã¤ã®å¤§ããªå¤æ´ã«ã¤ãã¦
3.1 Railtiesã®æ¸ãç´ã
generatorã¨Rails bindingsãæ¸ãç´ããã®ã¨åãããã«ãRailties(Railsã®ã³ã¢ã©ã¤ãã©ãª)ãæ¸ãç´ãããã
3.2 å ¨ã¦ã®Railsã³ã¢ãªã³ã³ãã¼ãã³ããççµåã«ãã
Merbã¨Railsãçµ±åããã«ããã£ã¦ã®å¤§ä»äºã¨ãã¦ãRailsã®ã³ã¢ãªã³ã³ãã¼ãã³ãã®å¯çµåãççµåã«ããã®ããã£ããããããéæãããã¨ã«ãã£ã¦ãå ¨ã¦ã®Railsã³ã¢ã³ã³ãã¼ãã³ãã¯ãã¿ããªãæ®éã«ã¢ã¯ã»ã¹ã§ããAPIã¨åãAPIã使ãããã«ãªã£ãããããã«ãã£ã¦ã©ããªèªä½ãã©ã°ã¤ã³ã§ããã©ããªç½®ãæãã³ã¢ã³ã³ãã¼ãã³ã(ä¾ãã°DataMapperãSequel)ã§ããRailsã®ã³ã¢ã³ã³ãã¼ãã³ããã¢ã¯ã»ã¹ã§ããå ¨ã¦ã®æ©è½ã«ã¢ã¯ã»ã¹ãããæ¡å¼µãããã§ããããã«ãªã£ããã
詳ããã¯ãã¡ã
3.3 Active Modelã«ããæ½è±¡å
ã³ã¢ã³ã³ãã¼ãã³ãã®ççµååã®ã²ã¨ã¤ã¨ãã¦ãAction PackããActive Recordãåãé¢ããããå ¨ã¦ã®æ°ããORMãã©ã°ã¤ã³ã¯Action Packã¨ä¸ç·ã«ä½¿ãããã«Active Modelãimplementããå¿ è¦ããããã
詳ããã¯ãã¡ã
3.4 ã³ã³ããã¼ã©ã®æ½è±¡å
ã³ã¢ã³ã³ãã¼ãã³ãã®ççµååã®ã²ã¨ã¤ã¨ãã¦ãHTTPã®æ¦å¿µã¨ã¯åãé¢ãã¦ãã¥ã¼ã®ã¬ã³ããªã³ã°ã管çãããã¨ãç®çã¨ããã¹ã¼ãã¼ã¯ã©ã¹AbstractControllerãä½ã£ãããActionControllerã¨ActionMailerã«å ±éããã³ã¼ããAbstractControllerã«ç§»åãã¦ã³ã¼ããã¹ãªã ã«ãããã
詳ããã¯ãã¡ã
3.5 Arelã¨ã®çµ±å
Arel(ã¾ãã®åã Active Relation)ã¯Active Recordã®ä¸å±¤ã«ä½ç½®ããã³ã³ãã¼ãã³ãã§Rails3.0ã§ä½¿ããã¦ããããArelãSQLã®æ½è±¡åãé¢é£ç³»ã®æ©è½ããµãã¼ããã¦ãããã®ã§Active Recordã®æ§é ãåç´ã«ã§ãããã
詳ããã¯ãã¡ã
3.6 Mail Extraction
TMailã®ã½ã¼ã¹ã³ã¼ãã«ããã¼ãµã¨éä¿¡åä¿¡ã¨ã¼ã¸ã§ã³ãã追å ããã¢ã³ãã¼ãããããã¦ãã®ãAction Mailerã®å§ã¾ãã ã£ãããRails3ã§ã¯ã¡ã¼ã«æç« é¢é£ã®æ©è½ã¯æ½è±¡åãã¦Mail gemã«ç§»ãããããã§ã³ã¼ãã®éè¤ãæ¸ã£ã¦Action Mailerã¨email parserã®éã®å¢çãå®ç¾©ãããããããã
詳ããã¯ãã¡ã
4 Documentation
Railsã®ããã¥ã¡ã³ãã¯å ¨ã¦ã®APIã®å¤æ´ã«è¿½éãã¦ã¢ãããã¼ããã¦ããã¨ããã ããããã«ãRails Edge guidesãå°ããã¤Rails 3.0ã®å¤æ´ãåæ ãã¦ãã£ã¦ããããã§ãRuby on Rails guidesã¯stableãªãã¼ã¸ã§ã³ã®Railsã ããè¼ãç¶ããã(3.0ããªãªã¼ã¹ãããã¾ã§ã¯2.3.5)
詳ããã¯ãã¡ã
5 å½éå
Rails3ã§ã®å½éåã®ãµãã¼ãã®ããã«ããããå´åããããããææ°ã®i18n gemã¯ãããæ©ãã§é²åãã¦ãã£ã¦ããã
- I18n㯠ActiveModel::Translation 㨠ActiveModel::Validations ãincludeããã°ã©ããªãªãã¸ã§ã¯ãã«ã使ããããããã¾ã§ORMæ¯ã«translationãå®ç¾©ãã¦ããã©errors.messages ã§å ¨ä½ã®ã¨ã©ã¼ã¡ãã»ã¼ã¸ãæ±ããããã«ãªã£ããã
- 2.3ã¾ã§ã¯Modelã®attributesåä½ã§ç¿»è¨³ããæååãå®ç¾©ãã¦ããã©ãããããã¯attributesåä½ã§(Modelã横æãã¦)ããã©ã«ãã®ç¿»è¨³ããæååãæå®ã§ããã
- ãã©ã¼ã ã®submitã¡ã½ããã¯èªåçã«formã«ã»ããããããªãã¸ã§ã¯ãã®ç¶æ ãè¦ã¦(æ°è¦ä½æãªã®ãå¤æ´ãªã®ã)ãããã«å¯¾å¿ããæååãåºåãããã
- ã©ãã«ã¯attributeã®ååãæå®ããã ãã§ç¿»è¨³ãã¦åºåããã
詳ããã¯ãã¡ã
6 Railties
ççµååã®éç¨ã§ãRailtiesã¯ä»ã®ãã¬ã¼ã ã¯ã¼ã¯ãã¨ã³ã¸ã³ããã©ã°ã¤ã³ã¨é£æºããããã«ç·ç¹æ¤ãåãããããªãã¹ãçã¿ãä¼´ããã«ãã¤ãªãã¹ãæ¡å¼µã§ããããã«ã
- ããããã®ã¢ããªã±ã¼ã·ã§ã³ã¯èªåã®åå空éãæã¤ããã«ãªã£ããä¾ãã°ã¢ããªã±ã¼ã·ã§ã³ã¯ "ã¢ããªã±ã¼ã·ã§ã³ã®åå".bootã§å®è¡ããããããã«ãã£ã¦ä»ã®ã¢ããªã±ã¼ã·ã§ã³ã¨ãã£ã¨ç°¡åã«é£æºã§ããããã«ãªã£ããã
- Rails.root/appã®é ä¸ã®ãã£ã¬ã¯ããªã¯å ¨ã¦load pathã«å ãããããããªã®ã§app/observers/user_observer.rbãªã©ãä½ã£ã¦ãç¹ã«load pathãããããã«Railsã¯ãããloadãããã
- Rails 3.0ã¯å ¨ã¦ã®configçãªå®ç¾©ã®ä¸å¿ã¨ãã¦Rails.configãªãã¸ã§ã¯ãã使ããã
railsã³ãã³ãã«ããrailsã¢ããªã®çææã«ãªãã·ã§ã³ã§test-unitãActive RecordãPrototypeãGitãªã©ã®ã¤ã³ã¹ãã¼ã«ãé£ã°ããã¨ãåºæ¥ããã-devãªãã·ã§ã³ã¯Railsã®ãªãã¸ããªãããã§ãã¯ã¢ã¦ããããã®ãæå®ãã¦Gemfileã«ãã®æ å ±ãæ¸ãè¾¼ãã§railsã¢ããªãçæãããã
詳ããæ å ±ã¯rails -helpã§ã¿ã¦ãã
Rails3.0ã§ã®Railtiesã®generatorsã¯ãã¡ããã¡ã注ç®ããã¦ãããåºæ¬çã«ã¯ãããªæã
- Generatorsã¯å®å ¨ã«æ¸ãç´ããã¦éå»ã®ãã®ã¨äºææ§ããªããã
- Railsã®templates APIã¨generators APIããã¼ã¸ãããã
- Generatorsã¯ãããã以ä¸ç¹å¥ãªpathããloadããããã¨ã¯ãªãããRuby load pathã§ããã¿ã¤ãããªãããä¾ãã°generators/foo_generatorãå¼ã³åºãããã«ã¯rails generate fooã¨ãããã
- æ°ããgeneratorsã¯ããã¯ãæä¾ããããtemplate engineãORMããã¹ããã¬ã¼ã ã¯ã¼ã¯ãªãããç°¡åã«generatorsã«ããã¯ã§ãããã
- æ°ããgeneratorsã¯RAILS_ROOT/lib/templatesã«ãã³ãã¬ã¼ãã®ã³ãã¼ãé ç½®ãããã¨ã§ãã³ãã¬ã¼ããä¸æ¸ãã§ãããã
- Rails::Generators::TestCaseã§èªåã®generatorsãä½ã£ã¦ãã¹ãåºæ¥ãã
generatorã«ãã£ã¦ä½ãããviewã«ã¤ãã¦ã®å¤æ´ç¹
- ããã¾ã§pã¿ã°ã使ã£ã¦ããã¨ããã«divã¿ã°ã使ãããã«ãªã£ãã
- Scaffoldsã¯editã¨newã®viewã«ãã³ã¼ãã®éè¤ãé¿ããããã«é¨åãã³ãã¬ã¼ãã¨ãã¦_formã使ã£ã¦ããã
- Scaffoldåºä½ãããformã§f.submitã使ã£ã¦ãã¦ãããã¯ãªãã¸ã§ã¯ãã®ç¶æ ãè¦ã¦"Create ModelName"ã¾ãã¯"Update ModelName"ã®valueã«ãªãã(i18nã®ç« ã§ãåããããªãã¨æ¸ãã¦ãã)ã
rakeã¿ã¹ã¯ã«ãäºã¤ã®è¿½å ãããã
- rake db:forward ã追å ãããããããã§migrationãä¸ã¤ã ãé²ãããæå®ããåã ãé²ããããã§ãããã
- rake routes CONTROLLER=x ã追å ãããããæå®ãããã³ã³ããã¼ã©ã®ã«ã¼ãã£ã³ã°ã ãã表示ãããã
Railtiesã¯ä¸è¨ã®ä¸ã¤ã®å®æ°ãå¤æ´ãã¦ãå¤ãæ¹ãéæ¨å¥¨ã«ããã
PLUGIN/rails/tasksã¨PLUGIN/tasksã¯ããã©ã®ã¿ã¹ã¯ã§ããã¼ããããªãããå ¨ã¦ã®ã¿ã¹ã¯ã¯PLUGIN/lib/tasksã«ãããã
詳ããã¯ãã¡ã
Discovering Rails 3 generators
Making Generators for Rails 3 with Thor