Sat 17 January, 2009

add to del.icio.us. look up in del.icio.us.
add to furl

- 说明
- 很多人喜欢使用函数puts,获取调试信息。这个问题类似于Java语言人们使用System.out.println(),获取输出内容。一旦使用了函数puts,无法保证网络服务器对于源代码输出信息的顺序!参见上图作了标记的两行输出记录。尽管在上面代码中,函数puts和logger.info是一前一后,但是输出信息的顺序与代码的顺序是不同的。
- 建议放弃使用函数puts,获取输出信息的方法。
- Rails框架已经集成了logger软件包!
- 什么是logger? What is logger?
add to del.icio.us. look up in del.icio.us.
add to furl
MountainWest RubyConf is on March 13-14, 2009 in Salt Lake City, UT and costs just $100.
That’s right, perhaps the most kick-ass RubyConf of the year cost only one. Hundred. Dollars.
BTW, I’ll be speaking at the conference.
See the list of speakers here
add to del.icio.us. look up in del.icio.us.
add to furl
January 10, 2009 -January 16, 2009
24 commits for edge Rails this week (with one patch ported over to the 2.2 branch as well). If you want a pre-release look at Rails 2.3, this is a fine time to install a copy of edge, if you’re not already there. It’s plenty stable enough for test sites, though there are a few rough patches yet.
Nested Transactions in Active Record
Several people contributed to a big patch that gives us nested transactions in Active Record, a much-requested feature. Now you can write code like this:
User.transaction do
User.create(:username => 'Admin')
User.transaction(:requires_new => true) do
User.create(:username => 'Regular')
raise ActiveRecord::Rollback
end
end
User.find(:all) # => Returns only Admin
Nested transactions let you rollback an inner transaction without affecting the state of the outer transaction. If you want a transaction to be nested, you must explicitly add the :requires_new option; otherwise, a nested transaction simply becomes part of the parent transaction (as it does currently on Rails 2.2). Under the covers, nested transactions are using savepoints, so they’re supported even on databases that don’t have true nested transactions. There is also a bit of magic going on to make these transactions play well with transactional fixtures during testing. commit
MemCacheStore Enhancements
Nahum Wild contributed some work that (inspired by his spandex_mem_cache_store plugin) that enhances the performance of Rails when using MemCacheStore. The basic idea is to keep a per-request local cache of requests sent to MemCacheStore, cutting down on unnecessary reads and leading to better site performance. commit
Making Active Record Callbacks behave
You may recall the spot in the Active Record documentation that says “If a before_* callback returns false, all the later callbacks and the associated action are cancelled.” What you may not know is that this is actually broken in the current version of Rails: if you cancel a before_update or before_create callback, the after_save callbacks still run. In Rails 2.3, this will behave the way that the documentation says it does. commit
Fractional seconds for TimeWithZone
The Time and TimeWithZone classes include an xmlschema method to return the time in an XML-friendly string. As of this week, TimeWithZone supports the same argument for specifying the number of digits in the fractional second part of the returned string that Time does:
>> Time.zone.now.xmlschema(6)
=> "2009-01-16T13:00:06.13653Z"
JSON Key Quoting
If you look up the spec on the “json.org” site, you’ll discover that all keys in a JSON structure must be strings, and they must be quoted with double quotes. As of this week, Rails does the right thing here, even with numeric keys. commit
Test Refactoring
Josh Peek spent some time refactoring various tests inside of Action Pack, including those for query string parsing, JSON parameter parsing, XML parameter parsing, multipart parameter parsing, and URL-encoded parameter parsing. While you won’t see any new functionality as a result of this work, it’s worth shining a spotlight on the often-thankless cleanup that keeps the Rails code in good shape.
Changes to Object#try
After some discussion, the semantics of Object#try have changed slightly: it now raises NoMethodError on private methods and always returns nil if the object is nil. commit
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlFri 16 January, 2009


- 说明:Google Quick Search Box
- 与Mac OS X软件Spotlight类似的搜索工具
- Google Quick Search Box不仅仅搜索本地信息,而且也可以搜索网络信息。
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
With the recent revitalization of the Rails Wiki project, we’re seeing people ask how the various pieces of Rails documentation fit together. I thought it might be useful to lay out how the Rails Activists see everything fitting together as we move forward.
Rails is a large and mature framework, with a lot of functionality – and with the Merb merger, there will be even more to learn in the future. As such, it presents challenges for developers at all levels trying to understand how to use Rails effectively. There are many resources to help with the learning process, including commercial books and magazines, screencasts and podcasts, tutorials, blog entries, and training courses. But there is also a series of official written documentation projects.
There’s no such thing as one-size-fits-all documentation. Different developers bring different skill sets, backgrounds, and levels of professional maturity to learning Rails. There are at least four levels of official documentation, overlapping but serving different needs:
- Inline documentation, with comments within the code itself (that you can see by running
rake doc:railswithin any Rails project). - Rails Guides
- Rails Book (a new project for Rails 3.0)
- Rails wiki
Although at first glance there appears to be substantial overlap, our feeling is that the each of these projects occupies a distinct (and valuable) niche.
RDoc
- Provides immediate help for syntax questions
- Maintained by the actual core developers and generally up-to-date
Rails Guides:
- Provides focused “how to” help for particular problem domains
- Target the mid-level developer, possibly with Rails experience
- Have a large amount of existing high-quality material
- Are already being continuously revised to track changes in edge Rails
- Can include version-specific tutorial code samples
- Can be delivered as a part of core Rails to provide “guidance at your fingertips” for new developers
Rails Book:
- Provides high-level architectural guidance and overview of how the pieces fit together
- Digs into the philosophy of the “Rails Ways”, so readers can understand why the framework works the way it does
- Targets the developer new to Rails or those wanting to go from the “trees” to the “forest” view
- Offers help in conceptualizing Rails and choosing between alternative modules (ORMs, routing DSLs, etc.) in the Rails 3 timeframe
- Can draw on the Merb experience in simultaneous translation and pulling in contributions from many writers
- Largely version independent
- Gives a structured path through end-to-end documentation in a way that standalone Guides do not
Rails Wiki
- Community-driven documentation that can respond rapidly to new software and new questions
- A good repository to links to external information
- Potentially a showcase for Rails itself in the underlying software
- A place to put the accumulated community knowledge, even the pieces that are not often needed
It’s important to note that we don’t see these four projects as entirely separate efforts that have no interaction with one another. In particular, it seems likely that the Book will link to the Guides for those seeking additional detail, while the Guides will link to the Book for those seeking additional high-level guidance. We also anticipate that the wiki will point readers to both Guides and Book (as well as to other sources of information).
So, what can you do to get involved? If you’re a writer, translator, or editor, any of these documentation projects would love to have your help:
- To contribute to the RDoc, write a Rails patch with good comments or check out the docrails project.
- To help the Rails Guides, get in touch with Pratik Naik or Mike Gunderloy, or drop by the #docrails channel on IRC freenode.
- To get involved with the Rails Book, contact Matt Aimonetti.
- To add to the Rails Wiki, join the rubyonrails-wiki group.
add to del.icio.us. look up in del.icio.us.
add to furlThu 15 January, 2009

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
I’m amazed that Raganwald would have any trouble scoring work. Or the kind of work he would enjoy (since, in the broad view, its easy to get a job, less easy to get a job you enjoy)
Seriously, what are people thinking? “Oh, he seems smart, but he doesn’t have the .Net chops with BizTalk experience we need.”
I’ve been fortunate the work with many smart people. Most of them were good at what they did, i.e., their “real” job, but some also had a knack for helping others get better at their job, too.
It wasn’t just a matter of straight-up mentoring; these people were able to offer a different point of view, ask the odd question, get people thinking about new things in new ways. It kept things fresh, made the work more fun. It’s one thing to tell people stuff, it’s another to get people to want to know and understand more stuff.
Alan Kay said, “At PARC we had a slogan: ‘Point of view is worth 80 IQ points.’ “
Smart, interesting people like Reg should be hired simply to go wander around a company, strike up conversations, and ease people into a different point of view. It would make the whole company smarter.
add to del.icio.us. look up in del.icio.us.
add to furlWed 14 January, 2009

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
So last week we were announced as activists, but what have we been doing? I’m sure there are some wondering, so here is our first report. Read on for news of our first big project, what each of us is working on, and how you can help today.
Firstly, we’ve been very pleased by the number of people who are actively interested in helping us improve the Rails ecosystem. Your input through UserVoice, the Activism Mailing List, Twitter, e-mail, and instant messages has been inspiring (and a bit overwhelming!). We listened, and one of the most popular requests revolved around the Wiki.

The Rails Wiki Reform
The Rails Wiki is in poor shape, for many reasons and it’s not one person’s fault. The good news is that our first major project is going to be revitalizing the wiki. To get our engines started, we’re forming a dedicated team to shape it into something the Rails community can be proud of.
If you’re interested in helping, simply join the Ruby on Rails Wiki Google Group. After you join, you’ll find a note on the group from Matt Aimonetti with more details.

What we’re doing
All of the Activists are busy with projects that fall under the general heading of “helping Rails.” Here’s a sampling of what we’re up to:
Gregg Pollack- Producing the Rails Envy Podcast.
- Working on a free “Scaling Rails” screencast series. Hoping to release close to the end of the month.
- Launching year 2 of the Ruby Hero Awards shortly.
- Promoting Ruby/Rails at OOP 2009 in Germany, then Acts As Conference in Orlando, FL.
- Putting together Case Studies.
- Investigating the current state of the Rails wiki and possibilities.
- Working on the Merb book (yes, Merb projects help Rails too).
- Doing Railscasts.com.
- Creating a Screencast application for aggregating Rails screencasts all into one feed on the RubyOnRails.org website.
- Covering This Week in Edge Rails on the official Rails blog.
- Working with Chad Woolley to improve the Rails CI server, including builds across multiple versions of Ruby and JRuby.
- Providing user support via #rubyonrails and #rails-activism on IRC freenode.
- Posting daily link roundups pointing to things of interest to Rails developers.

Other Stuff You Can Do
If you’re asking “What can I do today to help Ruby on Rails?”, aside from joining one of our mailing lists and collaborating with us, here are a few items that come to mind:
- Contact Matt Aimonetti if you think you have a good Case Study on Rails.
- Go to RubyForum or IRC and help new Rails developers.
- Go to your local Ruby Users Group, or start one.
- Go to a Rails related conference.
- The next time you tackle a hard problem in your rails app, write a blog entry.
- Take one of your Rails Libraries/Modules, and turn it into a Gem or Plugin.
- If you’re surfing Rails blog articles and you find one that is outdated leave a comment or let the author know the content should be updated or marked as obsolete.
Flickr Credits: Big Red Button Okinawa-Churaumi Aquarium marbles
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlTue 13 January, 2009

事实上,他们已经有了一些照着做的东西,比如,单元测试。有人和我们说,单元测试挺好,有一定价值,就是写起来太麻烦。为了覆盖到代码所有的分支,他不得不在单元测试里写下大量的代码,当时,我刚刚了解到,几百行的函数对他们而言,是小函数。
和我们合作的就是一个多多少少有些先行经验的项目组,当我们开始用我们的方式编写代码时,他们才意识到之所以测试难写,因为他们是照着原有的思路写代码,即便测试先于代码写出来。
另一个例子来自于Story分解。分析需求的时侯,客户的人告诉我们,他们已经开始将需求分解为Story了。当我们开始讨论需求的时侯,却发现这些Story并没有考虑过真正的价值,也没有考虑过开发和测试人员。
敏捷,似乎已经由许多人心目中的“奢侈品”变成了“消费品”。在各种各样的新闻、论坛和邮件列表,总是不断的看到有人说自己已经“敏捷”了。随之而来的,就是一些人以“过来人”的身份告诉后来者,敏捷不过如此。
敏捷看上去很简单,就是一大堆的敏捷实践,但真正有价值的部份却是敏捷的思想。因为一个实践推行不下去就置疑敏捷的人大有人在,而这才是真正需要下功夫的地方。
比如在C/C++如何做TDD。单纯从单元测试的角度出发,用一些单元测试框架,可以做。但是用敏捷的思路去考虑这个问题,我们需要的不仅仅是能做,而且需要快速反馈,一些单元测试框架的问题就会暴露出来。另外,为了做TDD,我们就需要将我们的单元隔离开来,这时侯,却发现这个单元的编译链接需要其他单元,或是过于庞大的头文件导致编译时间增长等等,那需要的就是一些设计和实现上的调整。
其实,从我们和客户的交流来看,即便没有真正的敏捷,而只是采纳一些敏捷实践,比如TDD、比如持续集成,对团队来说,都是有价值的,很多的问题不必等到最后才去发现,这就大大提高了产品的质量。
为什么很多人愿意倾向于那一些敏捷实践说事,说白了,因为它简单。扔下一句TDD不好做,容易,想办法把它做好,难!所以,我们做的是《非“敏捷”咨询》。
add to del.icio.us. look up in del.icio.us.
add to furl
“ A tremendous glimpse of the obvious. ”
Josh Silver
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlSun 11 January, 2009

Big props to Nick Sieger. His latest bit of super cool awesomeness is this :
As a result of some fruitful hacking at RubyConf 2008, I was able to modify JRuby so that gems can be loaded and used without having to unpack them. The feature became generally available with the 1.1.6 release last month. Gems in a jar!
add to del.icio.us. look up in del.icio.us.
add to furlSat 10 January, 2009

January 3, 2009 -January 9, 2009
It was a pretty light week for the edge Rails tree: about 20 commits. We’re starting to see things coalesce for a 2.3 release, though there’s no official release date yet. Here’s some of the highlights of what’s been going on.
AssetTag Timestamp Caching
You’re likely familiar with Rails’ practice of adding timestamps to static asset paths as a “cache buster.” This helps ensure that stale copies of things like images and stylesheets don’t get served out of the user’s browser cache when you change them on the server. You can now modify this behavior with the cache_asset_timestamps configuration option for Action View. If you enable the cache, then Rails will calculate the timestamp once when it first serves an asset, and save that value. This means fewer (expensive) file system calls to serve static assets – but it also means that you can’t modify any of the assets while the server is running and expect the changes to get picked up by clients. commit
Object#tap Backport
Object#tap is an addition to Ruby 1.9 and 1.8.7 that is similar to the returning method that Rails has had for a while: it yields to a block, and then returns the object that was yielded. Rails now includes code to make this available to older versions of Ruby as well. commit
Rack Version Bump
During the week, the Rack project released version 0.9 and Rails was quick to respond – the required version of Rack for Rails is now 0.9. So, if you’re running on edge, it’s time to update your gems. commit
Continuous Integration Setup
If you’re interested in setting up your own continuous integration server to build the Rails source, the embedded instructions have been updated with the latest requirements and clarifications. Even if you want a CI server for something else, they’re worth looking at, as they’ll get you from zero to a running cc.rb instance very quickly. commit
add to del.icio.us. look up in del.icio.us.
add to furl
