{"id":4590,"date":"2010-08-16T20:30:35","date_gmt":"2010-08-16T12:30:35","guid":{"rendered":"http:\/\/ihower.tw\/blog\/?p=4590"},"modified":"2011-04-09T01:48:57","modified_gmt":"2011-04-08T17:48:57","slug":"rails3-rc","status":"publish","type":"post","link":"https:\/\/ihower.tw\/blog\/4590-rails3-rc","title":{"rendered":"Rails3 RC \u767c\u4f48: \u91cd\u9ede\u5c0e\u89bd"},"content":{"rendered":"<div style=\"width:425px\" id=\"__ss_4989776\"><strong style=\"display:block;margin:12px 0 4px\"><a href=\"http:\/\/www.slideshare.net\/ihower\/rails3-changesets\" title=\"Rails3 changesets\">Rails3 changesets<\/a><\/strong><object id=\"__sse4989776\" width=\"425\" height=\"355\"><param name=\"movie\" value=\"http:\/\/static.slidesharecdn.com\/swf\/ssplayer2.swf?doc=rails3-changesets-100817063914-phpapp02&#038;stripped_title=rails3-changesets\" \/><param name=\"allowFullScreen\" value=\"true\"\/><param name=\"allowScriptAccess\" value=\"always\"\/><\/object><\/p>\n<div style=\"padding:5px 0 12px\">View more <a href=\"http:\/\/www.slideshare.net\/\">presentations<\/a> from <a href=\"http:\/\/www.slideshare.net\/ihower\">Wen-Tien Chang<\/a>.<\/div>\n<\/div>\n<p>RailsConf \u7d50\u675f\u4e4b\u5f8c\u5c31\u56b7\u56b7\u8981\u767c\u4f48\u7684 Rails 3 Release Candidate \u5019\u9078\u7248\u672c<a href=\"http:\/\/weblog.rubyonrails.org\/2010\/7\/26\/rails-3-0-release-candidate\">\u7d42\u65bc\u51fa\u4e86<\/a>(\u597d\u5427\uff0c\u662f\u4e09\u500b\u79ae\u62dc\u524d\u7684\u4e8b\u60c5\u4e86\uff0c\u9019\u7bc7\u62d6\u7a3f\u4e86 XD)\uff0c\u5982\u679c\u4f60\u9084\u6c92\u9032\u5834\uff0c\u53c8\u662f\u4e00\u500b\u597d\u6642\u6a5f\u3002\u5f9e\u6211\u4e0a\u6b21(\u7591\uff0c\u7adf\u7136\u662f\u534a\u5e74\u524d\u4e86!!)\u6574\u7406 <a href=\"http:\/\/ihower.tw\/blog\/archives\/3653\">Rails3 Beta \u767c\u4f48: \u91cd\u9ede\u5c0e\u89bd<\/a> \u4ee5\u4f86\uff0c\u53c8\u6709\u4e86\u4e00\u4e9b\u4e0d\u932f\u7684\u6587\u4ef6\uff0c\u7d93\u904e\u7b46\u8005\u904e\u6ffe\u6311\u9078\uff0c\u91cd\u65b0\u6574\u7406 Rails3 \u7684\u516b\u5927\u91cd\u9ede\uff1a<\/p>\n<p>1. Bundler<br \/>\n2. ActiveRecord \u7684\u65b0 Query API<br \/>\n3. ActiveRecord \u7684\u65b0 Validation API<br \/>\n4. Views: XSS, Block Helper, UJS<br \/>\n5. I18n<br \/>\n6. \u65b0\u7684 Routing API<br \/>\n7. \u65b0\u7684 ActionMailer<br \/>\n8. Metal<\/p>\n<p>\u5982\u679c\u559c\u6b61\u770b screencast\uff0c\u5b98\u65b9\u4e5f\u9304\u4e86 <a href=\"http:\/\/rubyonrails.org\/screencasts\/rails3\">rubyonrails.org\/screencasts\/rails3<\/a>\u3002<\/p>\n<h3>\u5b89\u88dd<\/h3>\n<p> \u5347\u7d1a\u5230 ruby 1.8.7 \u6216 1.9.2\uff0c\u4ee5\u53ca rubygems \u8981 1.3.6 \u4ee5\u4e0a<\/p>\n<pre>\r\n<code>\r\ngem update --system\r\ngem install rails --pre\r\ngem install mysql2\r\n<\/code>\r\n<\/pre>\n<p>\u958b\u59cb\u6539\u7528 mysql2 gem \u5427\uff0c\u9019\u4e00\u5957\u4fee\u6b63\u4e86 multithreaded \u53ca Ruby 1.9 \u7684 Encoding \u554f\u984c<\/p>\n<h3>\u5347\u7d1a<\/h3>\n<p>\u5982\u679c\u662f\u5347\u7d1a\uff0c\u91cd\u9ede Bundler \u548c Views \u90e8\u5206\u5fc5\u9808\u5148\u641e\u61c2\uff0c\u4e0d\u7136\u5b8c\u5168\u52d5\u4e0d\u4e86\u3002\u5176\u4ed6 API \u8b8a\u66f4\u7684\u90e8\u4efd(Routing, ActiveRecord, ActionMailer) \u5728 Rails 3.1 \u4e4b\u524d\u66ab\u6642\u662f\u53ef\u4ee5 works\u3002\u7576\u7136\u6709\u7a7a\u9084\u662f\u8d95\u5feb\u7814\u7a76\u4e00\u4e0b\u56c9\u3002\u4ee5\u4e0b\u662f\u5169\u7bc7\u6709\u95dc\u5347\u7d1a\u7684\u65b0\u6587\u7ae0\uff1a<\/p>\n<p>* <a href=\"http:\/\/www.railsdispatch.com\/posts\/upgrading-a-rails-2-app-to-rails-3\">Upgrading a Rails 2 App to Rails 3<\/a><br \/>\n* <a href=\"http:\/\/www.simonecarletti.com\/blog\/2010\/07\/the-way-to-rails-3\/\">The Road to Rails 3: make your Rails 2.3 project more Rails 3 oriented<\/a><\/p>\n<p>Rails \u672c\u8eab\u5347\u7d1a\u662f\u6c92\u6709\u554f\u984c\uff0c\u6015\u7684\u662f\u5468\u908a\u7684 Plugin \u6c92\u80fd\u8ddf\u4e0a\u3002<a href=\"http:\/\/railsplugins.org\">railsplugins.org<\/a> \u6709\u6574\u7406\u4e00\u4e9b\uff0c\u53ef\u4ee5\u627e\u627e github \u4e0a\u6709\u6c92\u6709 branch\uff0c\u800c Rails3 \u900f\u904e Bundle \u5b89\u88dd\u9084\u883b\u65b9\u4fbf\u7684\u3002<\/p>\n<h3>1. Bundler<\/h3>\n<p>* <a href=\"http:\/\/ihower.tw\/blog\/archives\/4464\">Bundler: Rails3 \u7528\u4f86\u7ba1\u7406 Gem dependencies \u7684\u795e\u5668<\/a><\/p>\n<h3>2. ActiveRecord Query Interface<\/h3>\n<p>Rails2 \u7684 finders, named_scope, with_scope \u7b49\u7528\u6cd5\uff0c\u5728 Rails3 \u7d71\u4e00\u70ba\u4e00\u7a2e Relation \u7528\u6cd5\uff0c\u53ef\u4ee5\u66f4\u5bb9\u6613\u505a composable(chainable)\u3001Decoupled from SQL \u4ee5\u53ca Lazy Loading\u3002\u53e6\u5916\u5982\u679c\u662f\u6709\u50b3\u53c3\u6578\u7684 scope\uff0c\u4e5f\u504f\u597d\u5b9a\u7fa9\u6210 class method\uff0c\u800c\u4e0d\u662f scope + lambda \u4e86\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4e0d\u932f\u7684\u6587\u7ae0\uff1a<\/p>\n<p>* <a href=\"http:\/\/m.onkey.org\/2010\/1\/22\/active-record-query-interface\">Active Record Query Interface 3.0<\/a> \u57fa\u672c\u7528\u6cd5\u4ecb\u7d39<br \/>\n* <a href=\"http:\/\/www.railsdispatch.com\/posts\/activerelation\">ActiveRelation: ActiveRecord Gets a Facelift<\/a> \u57fa\u672c\u7528\u6cd5\u4ecb\u7d39<br \/>\n* <a href=\"http:\/\/asciicasts.com\/episodes\/202-active-record-queries-in-rails-3\">Active Record Queries in Rails 3<\/a> \u57fa\u672c\u7528\u6cd5\u4ecb\u7d39<br \/>\n* <a href=\"http:\/\/asciicasts.com\/episodes\/215-advanced-queries-in-rails-3\">Advanced Queries in Rails 3<\/a> \u9032\u968e\u7528\u6cd5\u4ecb\u7d39<br \/>\n* <a href=\"http:\/\/edgerails.info\/articles\/what-s-new-in-edge-rails\/2010\/02\/23\/the-skinny-on-scopes-formerly-named-scope\/\">The Skinny on Scopes (Formerly named_scope)<\/a> \u9032\u968e\u7528\u6cd5\u4ecb\u7d39\uff0c\u8de8 Model \u7684 Scope \u592a\u53b2\u5bb3\u4e86\u3002<br \/>\n* <a href=\"http:\/\/blog.plataformatec.com.br\/2010\/07\/new-active-record-scoping-syntax\/\">New Active Record scoping syntax<\/a> \u5982\u679c\u4f60\u5728 Rails2 \u6709\u4f7f\u7528 with_scope \u6216  with_exclusive_scope( :find => x, :create => y ) \u8acb\u8b80\u9019\u7bc7\u3002\u65b0\u7684 Rails3 \u5efa\u8b70\u4f60\u6539\u7528 scoping, unscoped, create_with \u7b49\u65b0\u7528\u6cd5\uff0c\u56e0\u70ba\u820a\u7684\u7528\u6cd5\u884c\u70ba\u6709\u5dee\u7570\u3002    <\/p>\n<h3>3. ActiveRecord Validation<\/h3>\n<p>* AR Validation \u63d0\u4f9b\u4e86\u65b0\u7684 API \u53ea\u8981\u4e00\u884c\u5c31\u53ef\u4ee5\u6574\u5408\u540c\u4e00\u500b\u5c6c\u6027\u7684\u591a\u500b\u9a57\u8b49\uff0c\u53ef\u4ee5\u6e1b\u5c11\u884c\u6578\u3002<br \/>\n* \u53ef\u4ee5\u5ba2\u88fd EachValidator \u6574\u5408\u9032\u4e0a\u8ff0\u7684\u65b0 API \u4e4b\u4e2d<br \/>\n* \u53ef\u4ee5\u5ba2\u88fd Validator \u5305\u88dd\u4e00\u5927\u5806 validations\uff0c\u4f8b\u5982 validates_with ReallyComplexValidator<br \/>\n* save(false) \u7d42\u65bc\u62ff\u6389\u4e86\uff0c\u8981\u8df3\u904e\u9a57\u8b49\u5132\u5b58\u8acb save(:validate => false)<\/p>\n<p>* <a href=\"http:\/\/asciicasts.com\/episodes\/211-validations-in-rails-3\">Validations in Rails 3<\/a><br \/>\n* <a href=\"http:\/\/omgbloglol.com\/post\/392895742\/improved-validations-in-rails-3\">Improved validations in Rails 3<\/a><br \/>\n* <a href=\"http:\/\/lindsaar.net\/2010\/1\/31\/validates_rails_3_awesome_is_true\">validates :rails_3, :awesome => true<\/a><br \/>\n* <a href=\"http:\/\/edgerails.info\/articles\/what-s-new-in-edge-rails\/2009\/08\/11\/what-s-new-in-edge-rails-independent-model-validators\/\">Independent Model Validators<\/a><\/p>\n<p>\u53e6\u5916\u5c31\u662f\u9a57\u8b49\u932f\u8aa4\u7684 API \u4e5f\u6539\u4e86\uff1a<\/p>\n<p>* Errors#on \u8ddf on_base \u62ff\u6389\u4e86\uff0c\u8acb\u6539\u7528 Errors#[]<br \/>\n* Errors#add_to_base(msg) \u62ff\u6389\u4e86\uff0c\u8acb\u6539\u7528 Errors#[:base] << msg\n* Views \u88e1\u9762\u5e38\u7528\u7684 error_messages_for \u8ddf error_message_on Helper \u88ab\u62ff\u6389\u4e86\uff0c\u8acb\u81ea\u5df1\u5beb\u904e(\u4f60\u53ef\u4ee5\u53c3\u8003 scafffold \u7522\u751f\u51fa\u4f86\u7684\u7a0b\u5f0f)\u6216\u88dd\u56de <a href=\"http:\/\/github.com\/rails\/dynamic_form\">legacy plugin<\/a>\u3002<\/p>\n<h3>4. View<\/h3>\n<p>* <a href=\"http:\/\/ihower.tw\/blog\/archives\/3917\">Rails3 \u5982\u4f55\u63db\u4f7f\u7528 jQuery<\/a><br \/>\n* <a href=\"http:\/\/www.simonecarletti.com\/blog\/2010\/06\/unobtrusive-javascript-in-rails-3\/\">Unobtrusive JavaScript in Rails 3<\/a><br \/>\n* \u6240\u6709\u6709\u50b3 code block \u7684 Helper \u90fd\u6539\u6210 &lt;%= \u7684\u5f62\u5f0f\uff0c<br \/>\n\u8acb\u53c3\u8003 <a href=\"http:\/\/ihower.tw\/blog\/archives\/4225\">Rails3 \u5982\u4f55\u5beb Helper \u53ef\u4ee5\u50b3 Block \u53c3\u6578<\/a> \u4e00\u6587<br \/>\n* Rails3 \u8655\u7406 XSS: <a href=\"http:\/\/www.railsdispatch.com\/posts\/security\">Rails 3 Security Strategy<\/a>\uff0cHTML \u9810\u8a2d\u90fd\u6703\u9038\u51fa\u4e86\uff0c\u4e0d\u8981\u9038\u51fa\u8acb\u7528 raw Helper \u6216\u5b57\u4e32\u7684 html_safe! \u65b9\u6cd5\u3002<\/p>\n<h3>5. I18n<\/h3>\n<p>* \u8a5e\u5f59\u6a94\u4e2d\u7684\u8b8a\u6578\u66ff\u63db\u7531 {{}} \u8b8a\u6210 %{} \u4e86\u3002\u9019\u6709\u9ede\u60f1\u4eba\uff0c\u6211\u9084\u78b0\u5230 redmine \u7684\u554f\u984c(redmine \u4f7f\u7528 Rails2\uff0c\u4f46\u662f\u537b\u56e0\u70ba\u88dd\u4e86 Rails3 \u6240\u4ee5 i18n \u4e5f\u5347\u7d1a\u5230 0.4.1 \u7248\u672c\u5c31\u7206\u70b8\u4e86)<br \/>\n* \u63d0\u4f9b\u66f4\u591a backends\uff0c\u4f8b\u5982 <a href=\"http:\/\/github.com\/svenfuchs\/i18n\/tree\/master\/lib\/i18n\/backend\">ActiveRecord<\/a><br \/>\n* \u52a0\u901f\u529f\u80fd!! <a href=\"http:\/\/blog.plataformatec.com.br\/2009\/12\/run-i18n-run\/\">Run, I18n, run!<\/a><\/p>\n<h3>6. Routing<\/h3>\n<p>* <a href=\"http:\/\/ihower.tw\/blog\/archives\/3653\">Rails3 \u91cd\u9ede\u5c0e\u89bd\uff1a\u65b0\u7684 Routes<\/a><br \/>\n* <a href=\"http:\/\/www.engineyard.com\/blog\/2010\/the-lowdown-on-routes-in-rails-3\/\">The Lowdown on Routes in Rails 3<\/a> \u5f88\u8a73\u76e1\u7684\u7528\u6cd5\u4ecb\u7d39<br \/>\n* <a href=\"http:\/\/www.railsdispatch.com\/posts\/rails-routing\">The Powerful New Rails Router<\/a> \u9032\u968e\u7528\u6cd5<br \/>\n* <a href=\"http:\/\/asciicasts.com\/episodes\/222-rack-in-rails-3\">Rack in Rails 3<\/a> \u7d50\u5408 Rack \u7aef\u9ede\u7684\u61c9\u7528<\/p>\n<h3>7. ActionMailer<\/h3>\n<p>\u5e95\u5c64\u7531 TMail \u63db <a href=\"http:\/\/www.rubyinside.com\/ruby-email-library-2782.html\">Mail gem<\/a>\uff0c\u4e00\u6574\u500b\u780d\u6389\u91cd\u7df4 API \u5927\u6539\u3002\u539f\u672c\u52d5\u614b\u7684 Notifiter.deliver_welcome_email \u5beb\u6cd5\u8b8a\u6210 Notifiter.welcome_email.deliver\uff0c\u5176\u4e2d\u7684 Notifiter.welcome_email \u662f\u4e00\u500b Mail::Message \u7269\u4ef6\u3002<\/p>\n<p>* <a href=\"http:\/\/www.railsdispatch.com\/posts\/actionmailer\">A Whole New ActionMailer<\/a><br \/>\n* <a href=\"http:\/\/asciicasts.com\/episodes\/206-action-mailer-in-rails-3\">Action Mailer in Rails 3<\/a><br \/>\n* <a href=\"http:\/\/gist.github.com\/281420\">\u4e00\u500b\u7bc4\u4f8b<\/a><br \/>\n* <a href=\"http:\/\/lindsaar.net\/2010\/6\/7\/inline-attachments-for-actionmailer\">Inline Attachments for ActionMailer<\/a><\/p>\n<h3>8. Metal<\/h3>\n<p>* <a href=\"http:\/\/ihower.tw\/blog\/archives\/4561\">Rails3: \u65b0\u7684 Metal \u6a5f\u5236<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rails3 changesets View more presentations from Wen-Tien &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ihower.tw\/blog\/4590-rails3-rc\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Rails3 RC \u767c\u4f48: \u91cd\u9ede\u5c0e\u89bd\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[53,31],"tags":[],"class_list":["post-4590","post","type-post","status-publish","format-standard","hentry","category-rails","category-ruby","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1q6tG-1c2","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/4590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/comments?post=4590"}],"version-history":[{"count":21,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/4590\/revisions"}],"predecessor-version":[{"id":5514,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/4590\/revisions\/5514"}],"wp:attachment":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/media?parent=4590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/categories?post=4590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/tags?post=4590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}