共 37 篇文章 |
|
RoR的部署方式从架构上来说分为前端和后端:1、fcgi方式准确的说,不能叫做fcgi方式,其实就是启动一个ruby进程,让这个ruby进程监听一个tcp/unixsocket,以fcgi协议和前端通讯。值得一提的是,apache2.2的mod_fastcgi的方式和上面还不太一样,由apache动态创建fcgi进程和管理fcgi进程,这种方式和litespeed的lsapi面临的问题是一样的,此外apa... 阅326 转1 评0 公众公开 07-09-30 16:32 |
然后修改/etc/init.d/lighttpd,把LIGHTTPD_BIN=/usr/sbin/lighttpd改为LIGHTTPD_BIN=/usr/local/lighttpd/sbin/lighttpd 此脚本用来控制lighttpd的启动关闭和重起:/etc/init.d/lighttpd start /etc/init.d/lighttpd stop /etc/init.d/lighttpd restart 如果你希望服务器启动的时候就启动lighttpd,那么:chkconfig lighttpd on 这样lighttpd... 阅125 转1 评0 公众公开 07-09-30 16:30 |
Rails在一些基本功能上的实现:<% @books.each do |book| %><%= link_to book.title, :action => "show", :id => book.id %><%= book.buydate %><% end %>class BookController <ApplicationController scaffold :book def list @books = Book.find_all end def edit @book = Book.find(... 阅794 转5 评0 公众公开 06-12-06 14:02 |
routes.rb文件中,写入类似语句 map.connect ‘:controller/:action/:id‘ ,进行routing,习惯上称其为 route.2.优先级:先创建的 route 有高的优先级。 阅1480 转3 评1 公众公开 06-12-06 13:54 |
申明:本设置方式在windows 2003 enterprise sp1 和 windows xp sp2 中测试通过。1)为Rails app设置编码方式:这里把charset设置为gbk编码方式,我们知道每次request的时候,会产生一个和请求有关的controller object,因为每个通过script generate产生的controller class都是继承于ApplicationController的,所以每次请求都会对页面进行一次编码.2)... 阅663 转3 评0 公众公开 06-12-06 13:53 |
大家感兴趣的东西来了---Collecting Hash Arguments.一切都来源于Hash,使用 Hash Object 作为 Arguments,例如:这里的括号让人看的很不舒服,ruby允许在调用method的时候,去掉hash object的括号:puts test(:name=>‘kc‘,:des=>‘I like ruby‘)puts test(:des=>‘I like ruby‘,:name=>‘kc‘)kc---I like rubykc---I like ru... 阅519 转6 评0 公众公开 06-12-06 13:49 |
Methods and Blocks:我们前面谈到,在parameter前面加上一个*,表示在此method中,生成一个同名(不含*)的Array Object,同样的在parameter前面加上一个&,表示在此method中,生成一个同名(不含&)的Proc Object,什么是Proc Object?总的来说Proc class就是,使用block进行初始化,call method传递arguments到block中,返回值为bloc... 阅575 转4 评0 公众公开 06-12-06 13:49 |
def test(args1,args2)在前面的文章中,也提到过这样的定义方式,为此还讨论了ruby中多态(polymorphism),重载(overloading),覆盖(overriding)的问题,在《多态(polymorphism),重载(overloading),覆盖(overriding)和ruby》一文中提到,ruby是没有overloading的,但是ruby可以使用不同的参数列表,比如File.open等很多很多的meth... 阅839 转4 评0 公众公开 06-12-06 13:48 |
事务(transaction)决定了一段代码要么一起运行,要么一句也不运行。class File.def File.open_and_process(*args)f = File.open(*args)yield f.f.close()File.open_and_process("testfile","r") do |f|while line = f.gets.puts line.......未完。 阅428 转5 评0 公众公开 06-12-06 13:46 |