Blog信息 |
blog名称: 日志总数:1304 评论数量:2242 留言数量:5 访问次数:7570828 建立时间:2006年5月29日 |

| |
[Ruby on Rails]用rails写完一个小型blog系统后的感想 软件技术
lhwork 发表于 2007/2/7 9:05:10 |
看完<应用rails进行敏捷web开发>,马上动手开始写一个小型的个人blog系统,基本的功能都有了:
1.日志管理,使用了fckeditor,支持上传图片
2.链接管理
3.评论管理
4.分类管理
5.用户管理和blog设置
写的过程中没遇到什么大问题,有问题用google或者上railscn搜索下基本都能找到答案.时间都是晚上下班后无聊写着玩,在ubuntu下,装了radrails,用起来还蛮爽.
感想?YES,rails给我最大的感触就是 -----"敏捷",请注意,是敏捷,而非速度.我完全按照<应用rails进行敏捷web开发>迭代开发的思路来写,边写边改,雏形很快就出来了.rails非常方便的支持我重构代码和功能,我不需要痛苦的改写配置文件,不需要痛苦的重启服务器,不需要头痛于每次改动对整个系统的巨大影响...
下一步,是想好好把ruby学学,把rub |
|
[Ruby on Rails]rails的流程图 软件技术
lhwork 发表于 2007/2/7 9:04:37 |
读R4R,才读完第2章,前两章没什么新内容,算是复习吧
rails的lifecycle:
从浏览器发起一个请求的基本流程:
A.server to dispatcher
服务器通过你指定的路径查找dispatcher,比如,你在apache配置:
<VirtualHost www.r4rmusic.com> Se |
|
[Ruby on Rails]ruby如何动态new对象? 软件技术
lhwork 发表于 2007/2/7 9:04:06 |
来自railscn的讨论:
http://www.railscn.com/viewtopic.php?t=2289
1.eval "obj = #{str}.new" #只能在irb中使用 2.obj = eval "obj = #{str}.new" 3.obj = eval(str).new 4.c = Object.const_get("Array") s = c.new
相比于java的class.forName,与javascript等脚本语 |
|
[Ruby on Rails]〈ruby cookbook>第一章:String 软件技术
lhwork 发表于 2007/2/7 9:03:44 |
1.Building a String from Parts:
In ruby,String is mutable,you can build a String from a hash like this:
hash = { "key1" => "val1", "key2" => "val2" } string = "" hash.each { |k,v| string << "#{k} is #{v}/n" } puts string
2.Subsituting Variables into Strings:
Within the string, enclose the variable or expression in curly brackets and prefix it with a hash character. number = 5
"The number is #{number}." # |
|
[Ruby on Rails]Ruby如何动态调用方法? 软件技术
lhwork 发表于 2007/2/7 9:03:13 |
也就是反射机制咯,ruby cookbook有专门一章讲这个,调用方法可以使用
obj.method(:methodname).call的形式调用
如果要访问一个obj的一个实例属性值,可以通过
instance_variable_get("@obj")[:attr_name]
或者
instance_variable_get("@obj").send("@attr_name")
|
|
[Ruby on Rails]采用yaml读存配置文件 软件技术
lhwork 发表于 2007/2/7 9:02:34 |
java中为某个应用自定义配置文件,一般两种方式,采用*.properties或者xml文件,利用java.util.Property或者xml的API读或者存配置信息,如果配置信息多且复杂的话,解析xml是个不小的麻烦事。而ruby,我们可以采用yaml来存储配置信息。
举个简单例子:
users = [{:name => 'Bob', :permissions => ['Read']}, {:name => 'Alice', :permissions => ['Read', 'Write']}] 我们把它存在users文件:
open('users', 'w') { |f| YAML.dump(users, f) }
如果在rails的controller中调用上面的代码,将在此应用的根目录下生成一个users文件,如果你希望此文件放在model里,可以这样写:
|
|
[Ruby on Rails]Installing Ruby on Rails on Tiger 软件技术
lhwork 发表于 2007/2/7 8:59:11 |
This article is now out of date, and has been supplanted by a newer version, located here.
Many readers have written-in requesting instructions for manual installation of Ruby, Ruby on Rails, FastCGI, and Apache on Mac OS X 10.4 (Tiger).
Rather than making readers wait for the release of these instructions until a time when you can fully flesh them out with commentary, you h |
|
[Ruby on Rails]Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X 软件技术
lhwork 发表于 2007/2/7 8:56:28 |
This article is a major update to the older (but tried-and-true) post, Building Ruby, Rails, LightTPD, and MySQL on Tiger. Both Ruby, Rails, and their underlying infrastructure have come a long way in recent months, and this article will get you to a leaner, meaner Rails install in less time using fewer steps.
This article is updated on a regular basis as new versions of the software are released. |
|
|