??xml version="1.0" encoding="utf-8" standalone="yes"?>
django的原始码改动频繁
ORM API J琐Q后来按ActiveRecord风格重写Q?br />
没有整合的测试框?br />
没出书,文g相比Rails~Z甚多
python内部有h对django完全独立的一套full-stackpȝ有不同看法,又搞了很多别的框Ӟ比如turbogearsQ?br />
django对AJAX热潮无动D
相比h
Rails Team 相当E_Q很大?br />
ORM 太优了
出的书籍一U棒Q文件也相当?br />
Ruby 因ؓ(f)C,团结
Full Stack 框架QUnit Test 内徏
RJS 赶上 AJAX 热潮Q炒热不话?br />
虽然 Open Source 技术ؓ(f)本,但是撇开 Ruby on Rails 优秀的技术不谈?/p>
假如大家都不写文ӞRuby on Rails 的文件不够多的话Q有人敢用一个不熟?zhn)的语a吗?
没有?Ruby Cd攑֜ Rails w上Q写得出那麼?API 吗?
没有团结的团队,人员来来dQ吵来吵ȝ团队作得出好作品吗?
没有 DHH 肯花写程式以外的旉推销 Rails Qƈ且花眑֤旉写出一本Agile Web Development with RailsQ会(x)更多人愿意花旉d?fn)一个听都没听过Q也没有公司support ?Ruby on Rails 吗?
一向是一盘散沙的 Open Source C可以仔细思考一?Ruby on Rails 带给大家的啟C。Ruby C向心力强Q不分散力量Q又懂得Z以及(qing)掌握时势用RJS炒热话题。这说明Q团队管理好Q向心力强,行销强,正是 Ruby on Rails 扩散那麼快速的d。其实,q不正是一个好商业团队应该具备的特质吗Q?
The behind the scene code generation (aka: magic), the lack of a decent IDE, and worse, of a good debugger made my transition to Ruby somewhat difficult and sometimes confusing frustrating. I used to live in Visual Studio .NET and breath Intellisense. In fact, I still miss that to this day.
Any newcomer to Rails will quickly discover why it is so talked about. First of all, even though I don’t consider myself anywhere near a decent Rails programmer, I am now at least twice as productive with Ruby on Rails than with ASP.NET and C#. Thanks to the MVC (Model, View, Controller), DRY (Don’t Repeat Yourself) and Convention Over Configuration mindset of Rails. All the data access code is automagically generated for you (without running a code generator), templating is built in and creating AJAX’ed applications is a snap.
Life was good with Rails and the more I used it, the more I liked it. That was until early August of 2006. I was ready to launch version 2.0 of Ajaxwhois. Knowing so many professional Rails hackers, I thought deploying my application to my production server was going to be a breeze. I was wrong. Even though the installation of Linux (Ubuntu Dapper Drake 64 bit), Lighttpd, MySql and Mongrel went well, I experienced weird problems, mainly related to Mongrel. Sometimes, my Mongrel instances would simply die and disappear from the process list for no apparent reason. I didn’t have ANY traffic at this point because I hadn’t done DNS transfers yet. On other occasions, Mongrel went crazy and started peaking the CPU at 99%. I had to manually kill and restart it.
After extensive research and countless “from scratch” reinstalls, I found out that Mongrel was known to not play well with 64 bit Ubuntu (I lost the links to this evidence, unfortunately). Mongrel was patched accordingly, but it didn’t solve my problem. It still crashed many times a day and I just couldn’t figure out what was wrong. I asked my good friends Rich Collins and Adam Thorsen (of Guruza.com) who are both experienced Rails developers and they had no idea either. I was stuck.
I wanted to launch. Badly. I didn’t want to waste anymore time with this so I picked up a Python book and rewrote the whole site one more time, in Python using the Django framework this time. I had never programmed in Python before and much less used Django. However, the switch was easy enough since Ruby and Python are somewhat similar.
My experience with Python and Django was great; it is a combination every web developer should consider. However, I soon missed Ruby and Rails. Ruby supports “real” private/public/protected methods (Python just fakes that with its naming convention) and it’s syntax is more forgiving (the need for () at the end of each method call in Python was killing me). Django is not as straightforward as Rails, and requires more code to get things done. There are also many little things that don’t “feel right” in Django, like the need to manually pass variables to a view. Data access is confusing at best while Rails’ ActiveRecord is god-sent. These little things really add up.
On the flip side, Python is faster than Ruby and less memory hungry. I was also surprised to actually love Python’s significant indentation (see example). But more importantly, Python and Django just worked! I never experienced weird crashes like I did with my Rails stack.
So, why am I back to Rails for my next project? 3 letters: FUN. I find Ruby and Rails to be pleasant to use. The community large, active and very helpful. The number of freely available Rails plugins and the fast evolution of the core code are also welcomed additions. Rails requires less code, less self.__awkward_method_calls(), has built-in AJAX and REST support, and has much more flexible data access and templating engines.
But what about those crashes? What about the speed issue? Well, I don’t have the crashes anymore. Don’t ask me why, I don’t know, but it’s fine now, I swear! Something somewhere got fixed and it seems to have solved the problem. However, speed is still one of the low points of Rails. Using caching and proper code optimization should take you a long way, though. Matz, the author of Ruby, is working hard on a new virtual machine that should make Ruby just as fast, if not faster than Python.
My recommendation is, try both for long enough to figure out what works and what doesn’t for you. If you are a long-time Python user, Django might be more compelling for you, but if you are coming from a Java, Perl or Smalltalk background, Ruby and Rails will most likely be what you’ll end up using. Either way, I don’t think you can go wrong.
PS: I don’t want to blame Mongrel for my Rails problems because I am still not sure who was the guilty party. Mongrel is a wonderful piece of software and I heartily recommend it. Just make sure you watch it closely if you use Ubuntu on a 64 bit machine.
局部变量,Ҏ(gu)参数和方法名U应该用一个小写字母开头或者用一个下划线开?
全局变量用美元符作ؓ(f)前缀$;
实例变量使用@开_(d)
cd量用@@
cdQ模块名和常量应该用大写字母开?/p>
RubyE序代码现在?位的ACSII码来表示Q通过语言扩展来支持EUCQSJIS或UTF-8{?位编码系l。Ruby2.0版本支?6位的Unicode~码
puts print gets
printf "Number: %4.3f, String:%s", 7.8, "hi!"
数据cdQ数字,字符Ԍ数组Q哈希表Q区_(d)正则表达?br />
1..5 ---> 1,2,3,4,5;
1...5 ---> 1,2,3,4
a=1; b=1.0; a==b #true 比较两个对象的值是否相{?br />
a=1; b=1.0; a.eql?(b) #false 比较两个对象的g?qing)类型是否相{?br />
a=1.0; b=1.0; a.equal?(b) #false 比较两个对象在内存中的地址是否相同
a=1.0; b=a; a.equal?(b) #true
<=> 比较两个对象的大,大于Q等于,于 分别q回1Q?Q-1
===双的对象是否在左边区间之内Q返回true和false
puts (0..9) === 3.14 #true
puts ('a'..'f')==='c' #true
=~用来比较是否W合一个正则表辑ּQ返回模式在字符串中被匹配到的位|,否则q回nil
!~断言不符合一个正则表辑ּQ返回trueQfalse
break,跛_当层循环
next,忽略本次的@环的剩下部分Q开始下一ơ的循环
redo,重新开始@环,q是从这一ơ开?br />
retryQ重头开始这个@环体
times,upto,downto,each.step
3.times{print 'Hi'} #HiHiHi
1.upto(9) {|i| print i if i<7} #123456
9.downto(1){|i| print i if i<7} #654321
(1..9).each{|i| print i if i<7} #123456
0.step(11, 3){|i| print i} #0369
异常处理begin/end...rescue...ensure...raise retry可以用在rescue?/p>
attr_writer:motherland
相当?br />
def motherland=(value)
return @motherland = value
end
attr_reader:motherland
相当?br />
def motherland
return @motherland
end
attr_accessor:motherland 相当?attr_reader:motherland; attr_writer:motherland
def user_list @user_pages, @users = paginate(:users, :order_by =Q?'name') end |
QtableQ? QtrQ<thQ姓名</thQ</trQ? Q? for user in @users %Q? QtrQ<tdQ<%= user.name %Q</tdQ? Q? end %Q? Q?tableQ? QhrQ? Q?= pagination_links(@user_pages) %Q? QhrQ? |
http://www.itpub.net/forum61.html
里大多有下,重点推荐
Programming Ruby 2nd edition
Agile Web Development with Rails
一些不错的论坛 ?qing)网?br />国内?br />http://railscn.crispynews.com/
http://www.railscn.com
http://chinaonrails.com
http://r4rclub.schtuff.com/
http://forum.javaeye.com
http://rorwiki.hellopen.net
国外?br />http://www.ruby-forum.com/
http://www.rubyonrailsforum.com/rails-code-questions/
http://rubyforge.org/
http://www.rubyonrails.org/
http://www.ruby-lang.org/en/
http://www.webrick.org/
http://www.yaml.org/
blog
<博客>
铁道播客Q有诸多视频教程
http://rorcast.blogger2blogger.com/
my4java的文字博客:(x)有很多教E的译稿、笔记等
http://my4java.itpub.net/
cnruby道喜技术日讎ͼ(x)众多实例教程
http://www.hhtong.com/blog1/
caphe的博?
http://www.aygfsteel.com/cap
Caiwangqin的博?
http://www.uuzone.com/blog/uu_1115110/
中文RubyOnRailsWiki
http://rorwiki.hellopen.net/index.p...%A6%96%E9%A1%B5
关于rails和ajax相结?br />http://www.rubynoob.com/
q个当中有一些介l?br />http://www.railscn.com/about704.html