123
 123

Sun 07 December, 2008

Sat 06 December, 2008

Click here to bookmark this link.Channel Image08:57 New REE with OS X, 64-bit, Solaris support and GC patches» Riding Rails - home

Phusion is on a roll today. Not only did we just get a new Passenger, they’ve also just dropped a new REE (the Ruby patches for copy-on-write) that includes 64-bit support as well as compatibility with OS X and Solaris. They’ve also fitted the excellent RailsBench patches from Stefan Kaes that allows you to tweak the GC settings in Ruby if you need to.

This edition was sponsored by 37signals, Curve21, Dr Dispatch Transportation Software, InfoEther, Martian Interactive, New York Times, Shopify, Trevor Turk, and Utah Imaging.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:57 Three Days With the Roku Netflix Player» Joey Gibson's Blog
My Netflix Player arrived on Wednesday. It was supposed to be a family Christmas present, but you know how those things go. When something this cool arrives this early, there’s no way it’s going to stay boxed up for three more weeks. The box is very small, maybe 4.5 inches on a side, and about 2 [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Fri 05 December, 2008

Click here to bookmark this link.Channel Image23:34 This Week in Edge Rails» Riding Rails - home

November 29-December 5, 2008 Edition

Rails 2.3 development is still continuing at a healthy clip. Here’s an overview of what’s happened this week.

Application Templates

Rails now incorporates Jeremy McAnally’s rg application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the rails command. Pratik Naik provided a thorough writeup of this feature over on his blog. commit

Find Improvements

Even the venerable code used by Active Record to talk to databases can be improved, and we had a couple of improvements checked in this week. First, the SQL generated for preloading records in has_and_belongs_to_many associations has had an extra “AS” excised, which makes it work better with some databases. Also, we now have a :having option on find (as well as on has_many and has_and_belongs_to_many associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:


developers =  Developer.find(:all, :group => "salary", 
  :having => "sum(salary) >  10000", :select => "salary")

commit commit

Rack Integration

The tighter integration of Rails with Rack continues. This week saw the death of the venerable CGI processor within Rails, as well as the use of Rack to handle FCGI. There was also some refactoring down in the Rails tests to make them play nicer with Rack. commit commit

Configuration File Cleanup

Over the years, the default environment.rb file had gotten a bit cluttered with comments, random documentation, and settings that mot people don’t need. DHH took a few minutes to clean up the mess, and the current state of this file is much leaner. As part of the cleanup, session store configuration has been moved out to its own file. commit

No More Process Scripts

If you’re one of the (fairly rare) Rails developers who deploys in a fashion that depends on the inspector, reaper, and spawner scripts, you’ll need to know that those scripts are no longer included in core Rails. For Rails applications that are reployed with current alternatives like Passenger, these are just unnecessary baggage. But if you need them, you’ll be able to pick up copies via the irs_process_scripts plugin. commit

Odds and Ends

The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don’t generally set things up right. If that’s you, you can now set ActionController::Base.ip_spoofing_check = false to disable the check entirely. commit

Rails.root now returns a Pathname object, which means you can use it directly with the join method to clean up existing code that uses File.join. commit

ActionController::Dispatcher now implements its own middleware stack, which you can see by running rake middleware. commit

Gem loading is smarter about missing dependencies. commit

auto_link now properly applies options (such as :target and :class) to generated e-mail links. commit


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image23:34 Phusion Passenger 2.0.5 now compatible with Edge Rails» Riding Rails - home

The Phusion team keeps blazing ahead with Passenger and improving it rapidly. They’ve just released version 2.0.5, which includes a few fixes and introduces compatibility with the Rack-based Edge Rails.

At 37signals, we’ve already switched over Ta-da List and are busy working on getting the rest of our suite running on Passenger. It’s just so much easier to deal with and the memory savings you get through REE are a nice cherry on top.

I keep getting a steady stream of success reports from all over the world as well. I’ve even read of a few people getting back into Rails development because Passenger finally took out the inconvenience of deploying.

It’s hard to argue with the usability. I’ve personally been setting up a new server running Ubuntu 8.10 and using Apache 2 with Passenger. The time it took me to go from a fresh install to a complete production setup was ridiculously low. There’s just so much less to worry about.

If you haven’t given Passenger a chance yet, now is definitely the time.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:48 Cucumber实例世界:Cucumber on Rails深化实例(四)» 天天红玉世界
Cucumber on Rails深化实例(四)
 

警告:在复制本博客代码时,空行存在中文空格,需要删除!!!

Cucumber on Rails深化实例
rails 04_demo_cucumber && cd 04_demo_cucumber
 
ruby script/generate cucumber
 
vi features/support/env.rb
require 'cucumber/rails/rspec'
require 'webrat' if !defined?(Webrat)
 
vi lib/tasks/cucumber.rake
# 在format和language之前是两个“-”,其它地方也是如此。
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "—format pretty —language zh-CN"
 
rake db:migrate
 
rake features
 
ruby script/generate rspec_scaffold post title:string body:text
 
ruby script/generate feature post title:string body:text
 
vi features/step_definitions/webrat_steps.rb
#require 'webrat' if !defined?(Webrat) # Because ...
 
rake db:migrate
 
vi features/manage_posts.feature
功能:管理帖子
为了能够控制“帖子MVC”
作为软件普通用户
我要完成“帖子MCV”创建和删除帖子的功能
 
场景: 创建一个新的帖子
假如 我已经在创建新帖子页面
当 我在输入框<post_title>中输入内容<lycom.de是什么网站>
而且 我在输入框<post_body>中输入内容<lycom.de是一个Ruby/Rails技术新闻博客>
而且 我点击按钮<Create>
那么 我应该看到<lycom.de是什么网站>
而且 我应该看到<lycom.de是一个Ruby/Rails技术新闻博客>
 
场景: 删除第一个帖子
假如 存在<4>个帖子
当 我删除第一个帖子
那么 还应该有<3>个帖子
 
vi features/step_definitions/post_steps.rb
require 'spec'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
 
Given /我已经在创建新帖子页面/ do
visits "/posts/new"
end
 
When /我点击按钮<(.*)>/ do |btn_name|
clicks_button btn_name
end
 
Given /存在<(\d+)>个帖子/ do |n|
Post.transaction do
Post.destroy_all
n.to_i.times do |n|
Post.create! :title => "Post #{n}"
end
end
end
 
When /我在输入框<(.*)>中输入内容<(.*)>/ do |id,text|
fills_in(id, :with => text)
end
 
When /我删除第一个帖子/ do
# @post = Post.find(:first)
# visits "/posts/#{@post.id}"
visits posts_url
clicks_link "Destroy"
end
 
Then /^我应该看到<(.*)>/ do |text|
#response.body.should =~ /#{text}/
response.body.should =~ Regexp.new(text)
end
 
Then /还应该有<(\d+)>个帖子/ do |n|
Post.count.should == n.to_i
response.should have_tag("table tr", n.to_i + 1) # There is a header row too
end
 
# 这个命令输出结果就是上面图
rake features 
或者
ruby script/cucumber -a zh-CN features/manage_posts.feature

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

Thu 04 December, 2008

Click here to bookmark this link.Channel Image11:51 Apple世界:通用即时通讯工具Adiumx» 天天红玉世界
通用即时通讯工具

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

Wed 03 December, 2008

Click here to bookmark this link.Channel Image23:57 图书世界:免费的RJS教程» 天天红玉世界
免费的RJS教程
  • 说明
    • RJS教程是使用早期的Rails版本为基础的
    • RJS中文教程不是完整的翻译版本
    • 谁来着手以Rails 2.2版本重新写该教程的命令?

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image05:15 First Steps in Rails (on Heroku)» O'Reilly News:Ruby
If you want to explore Rails, heroku.com offers an easy way to get started, using a web-based interface that neatly hides the complexity of installation and database management.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image00:41 Roxy: Ruby代理库» LetRails
Roxy是Ryan Daigle写的一个Ruby代理库,它可以让你轻松的向关联对象添加方法,就像has_many为关联对象添加的build和create方法那样,比如: require 'roxy' class Person   include Roxy::Moxie   attr_...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 02 December, 2008

Click here to bookmark this link.Channel Image19:34 网站推荐:获取网络世界知识的快速途径www.yeeyan.com» 天天红玉世界
Click here to bookmark this link.Channel Image18:19 闲杂书等» 梦想风暴
按照老妈的说法,我很小就对书有了浓厚的兴趣。那时,老妈还是一个老师,为了丰富自己,准备进修,于是每天晚上要在家里学习。每当她拿起书要读的时侯,我就会恰如其分的出现,争抢书和笔。结果是,老妈的书没读成,后来,也不做老师了,而我却养成了读书的兴趣,算是接过了老妈的班。

当读书成为一种常态,有一段时间不读书,自己就会觉得空虚。之前,空虚了一段时间,突然觉得对不起自己,于是,又开始新一轮的读书。老妈给了我一个还算好用的脑子,当我扔下书本,隔一段时间再捡起来,思维居然还有连续性。所以,我可以并行读几本书。

费马大定理》,这是一本数学八卦,非常好看。数学,是一种美,非常严谨的美。当时报考大学的时侯,如果没有计算机专业的话,我很可能会去学数学,我喜欢数学的那种美,也喜欢问题成功解决那一瞬间的快感,就如同程序顺利运行的那一瞬给我的感觉。《费马大定理》讲述了费马大定理的证明过程,作者非常八卦的把证明前前后后涉及的种种人和事谈了一遍,完全就是一个数学发展史,远到毕达哥拉斯定理,近到椭圆方程。好书好译,让这书读起来异常流畅。读这本书时,有一种力量,牵引着我,让我不忍放下。上一本给我这种感觉的书是《达芬奇密码》。当然,由于这是一本跟数学相关的书,所以,其中会一些定理的简单推导过程,即便是作者解释得非常清晰,仍会有一丝障碍,“好读书,不求甚解”或许是最好的解决方案。

之所以会读《费马大定理》,主要是最近又对数学有了兴趣,而这个兴趣来自《什么是数学》。

    如果一个数的各位数字之和能够被3(或9)整除,则这个数可以被3(或9)整除。

怎么样,勾起童年回忆了吧!《什么是数学》给出一个非常清晰的证明,让人一看便知。《什么是数学》算是一本科普读物,问题讲得行云流水一般,数学的严谨之美在这本书体现得非常明显。在我看来,当年学的数学知识只是一个个零散的点,而这本书把这些点串了起来,所以,很多原来不那么清楚的地方,似乎变得再清楚不过了。不过,这必竟不是小说,不可能那么一下子就完全理解,所以,慢慢来,好好读。

只有当认识问题到一定深度之后,才可能用浅显的方式讲出来,《什么是数学》如此,《万历十五年》也如此。

记得很小的时侯,老妈送给我一本像新华字典一样的小册子,里面有各种各样的知识,我对它爱不释手。其中,这本书的后半部份讲的是中国历史,这也形成了我对中国历史最初的认识。想来,对历史的兴趣和现在停留在脑子里面的历史知识,大多是来自那本小册子。

《万历十五年》,一本关于明朝历史的书。那些面孔严肃的教科书太不受人喜欢,于是,有了《明朝那些事儿》之类的文字出现。相比之下,《万历十五年》是一本居于二者之间的书,不似教材般刻板,不似明月般调侃。一位深刻洞察力的历史学家像讲故事一样讲历史,历史变得生动起来。在这本书里面,你会看到做人臣难,当皇帝也不容易;会看到政治的阴阳;会看到冰冻三尺非一日之寒;会看到那些我们印象中的那些忠臣,也符合“人非完人”的规律……

其实,这段时间并行读的书还有一些,但大多是一些技术书籍,这里已经聊了太多和技术相关的内容,所以,才会有了《闲杂书等》。




add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:10 self.facts.randomly_select(7)» James Britt - Code, Content, Caffiene

That’s not actual code; I made that up.

Here’s something not made up: Stellar talent Daniel Davis has challenged me to present seven random facts about myself.

I’m not a fan of anything that smacks of a chain-letter, but Daniel rules so I’ll at least spew out some unneeded detail. (But I won’t be inflicting this on on seven other people. Feel free to take up the challenge on your own if you feel so inclined.)

0. Favorite color: Plaid
1. Born and raised on an island
2. First cat was named George Sand
3. First 45 RPM vinyl single bought: Frankenstein by Edgar Winter Group
4. Learned FORTRAN in college by coding cellular automata for a semester. Still do not understand how I passed the Numerical Analysis with FORTRAN course since, oddly enough, CA were not on any test or assignment.
5. Have never skied
6. Favorite movie is Metropolis, unless it’s Citizen Kane or Animal House


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:09 Cucumber实例世界:Cucumber on Rails最简单实例(三)» 天天红玉世界
Cucumber on Rails最简单实例
Cucumber on Rails最简单实例
rails 03_demo_cucumber && cd 03_demo_cucumber
 
ruby script/generate cucumber
 
vi features/support/env.rb
require 'cucumber/rails/rspec'
require 'webrat' if !defined?(Webrat)
 
vi lib/tasks/cucumber.rake
# 在format和language之前是两个“-”,其它地方也是如此。
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "—format pretty —language zh-CN"
 
rake db:migrate
 
rake features
 
ruby script/generate rspec_scaffold post title:string body:text
 
script/generate feature post title:string body:text
 
vi features/step_definitions/webrat_steps.rb
#require 'webrat' if !defined?(Webrat) # Because ...
 
rake db:migrate
 
vi features/manage_posts.feature
Scenario: Register new post
Given I am on the new post page
When I fill in "post_title" with "My post title:string"
And I fill in "post_body" with "My post body:text"
And I press "Create"
Then I should see "My post title:string"
And I should see "My post body:text"
 
vi features/step_definitions/post_steps.rb
#Post.create! :name => "Post #{n}"
Post.create! :title => "Post #{n}"
 
# 这个命令什么也没有输出!说明了什么?为什么?
rake features
 
# 这个命令输出结果就是上面图
ruby script/cucumber -a en features/manage_posts.feature

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

Mon 01 December, 2008

Click here to bookmark this link.Channel Image07:27 Rails2.2世界:国际化功能问与答(三)» 天天红玉世界
国际化功能问与答(三)
 

警告:在复制本博客代码时,空行存在中文空格,需要删除!!!
 

  • 国际化功能问与答(三):本地化翻译方法
    • 如何调用翻译函数?
      I18n.translate < key >
      如:
      I18n.translate :hello
      或者
      I18n.t :hello
    • 如何调用具有插值的翻译函数?
      I18n.translate < key >, < 插值 >
      如:
      I18n.translate :hello_with_name, :name=>”Hans”
    • 如何调用多元化的翻译函数?
      I18n.translate < key >, < 多元化变量 >
      如:
      I18n.translate :second_in_words, :count=>12
    • 如何调用具有命名空间的翻译函数?
      I18n.translate < 命名空间.key >, < 多元化变量 >
      如:
      I18n.translate “namespcae.second_in_words”, :count=>2
    • 如何调用时间对象的本地化函数?
      I18n.localize < 时间对象 >, :format=>< key >
      如:
      I18n.localize Time.now, :format=>:long
      或者
      I18n.l Time.now, :format=>:long
    • 如何调用日期对象的本地化函数?
      I18n.localize < 日期对象 >, :format=>< key >
      如:
      I18n.localize Date.parse(‘2008-11-29’)
    • 如何调用时间和日期名称的翻译函数?
      I18n.translate < 命名空间.key >
      如:
      I18n.translate(‘date.month_names’)
      I18n.translate(‘date.month_names’).last
如何使用本地化文件的实例方法
rails 03_i18n_demo && cd 03_i18n_demo
 
vi config/environment.rb
config.i18n.default_locale = :"zh-CN"
 
touch config/locales/zh-CN.yml
vi config/locales/zh-CN.yml
zh-CN:
hello: "世界,你好!"
 
hello_with_name: "{{name}},你好!"
 
second_in_words:
one: "一秒钟"
two: "两秒钟"
other: "{{count}}秒钟"
 
namespace:
second_in_words:
one: "一秒钟"
two: "两秒钟"
other: "{{count}}秒钟"
 
time:
formats:
default: "%Y年%b%d日 %A %H:%M:%S %Z"
short: "%b%d日 %H时%M分"
long: "%Y年%b%d日 %H时%M分%S秒"
am: "上午"
pm: "下午"
 
date:
formats:
default: "%Y年%m月%d日"
abbr_default: "%Y-%m-%d"
short: "%b%d日"
long: "%Y年%b%d日"
day_names: [星期天, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
abbr_day_names: [日, 一, 二, 三, 四, 五, 六]
month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月]
abbr_month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月]
order: [ :year, :month, :day ]

    • 在图中的命令sc就是“ruby script/console”命令。

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:09 RubyConf2008 videos now appearing online» James Britt - Code, Content, Caffiene

Sun 30 November, 2008

Click here to bookmark this link.Channel Image18:34 Zum ersten Advent» chris blogs

Die Polemik zum Christkindlesmarkt von letztem Jahr gilt immer noch, aber da ich nun die meiste Zeit in München verbringe, tangiert mich das nur wenig. In München gibts natürlich auch Weihnachtsmärkte.

An der Adventskalenderfront stehen mal wieder an:

Dieses Jahr Sterne mit Zirkel und Lineal konstruiert. 5-zackige, 17-zackige oder, wenn’s beliebt, 257- und 65537-zackige!

NP: Bearries—Explorer One


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