2008年3月5日

Rails 上传

状态:

解决方案:http://swfupload.org/project swfupload,易学易用,1分钟即可完成配置,弱智级应用,谁用谁知道!

描述

swf 生成图表插件

状态:

解决方案:http://ziya.liquidrail.com/**尚未试用

描述

Rails 建模工具

状态:

解决方案:http://railroad.rubyforge.org/**尚未试用

posted @ 2008-03-05 10:08 Janpoem 阅读(103) 评论(0) 编辑

转自:http://lightyror.thegiive.net/


Friends for Sale 是一個在 FaceBook 上面排行前十的 Facebook App,最近他公佈他的資料,他是 Ruby on Rails 寫的。他上面有 60萬個會員,一個月 3億個 PV,並且以每個月 300%繼續成長。上個月流量是 3T,不過大部份都是圖片的支出。

架構是標準的 Rails Cluster,Front end 是 Nginx,Application Server 是 Mongrel。

他們學到課程如下

  1. 如果在Facebook 上面開發 APP,一開始就要想到 Scaling Problem(四周就衝到 1 m pv/day)

  2. Ruby on Rails can scale

  3. Performance Problem 是在 DB,你需要有很好的 DBA

  4. Cache 用的好,DB 不嫌少

他們使用

  1. Ruby on Rails

  2. CentOS 5

  3. Memcached

  4. MySQL 5.1

  5. Nginx

  6. Starling( Distribute Queue Server)

  7. Dr. Nics Magic Multi-Connections Gem ( Read Write 不同個 DB)

使用硬體

  1. 6台 4 core 的 App Server,每台 16 Mongrel Instance,並且每台都放 4GB Memcached 。

  2. 4 台 DB Server,上面配備 32GB 4 core servers with 4x 15K SCSI RAID 10 disks,使用 Master-Slave,用 Multi-Connection Gem 來達成 Read Write 不同 DB。

  3. 1 Starling Server

  4. 1 frontend server
posted @ 2008-03-05 09:19 Janpoem 阅读(165) 评论(0) 编辑
Rails 2.0.2以后,原来的分页类paginate没作为基准类了,而是依赖plug in——will paginate。

will_paginate的代码写得不错,不过没支持Ajax,动手改造了一下,哈,效果还行(其实以前paginate的时候已经自己封装了一个方法用于处理ajax分页)。

改动很小,大家不用惊呼,主要改动如下:

/plugins/will_paginate/lib/will_paginate/view_helpers.rb

原代码82行左右,加入传入参数:ajax_options = nil

def will_paginate(collection = nil, options = {}, ajax_options = nil)

原代码95行左右,创建新renderer_class实例,加入以下调用参数

renderer = renderer_class.new collection, options, ajax_options, self

原代码118行左右,renderer_class类构建,加入调用参数

def initialize(collection, options, ajax_options, template)

原代码122行左右,增减一个实例变量,用于存储传入的ajax_options:

@ajax_options = ajax_options

原代码187行左右,是输出页面翻页链接,增加对@ajax_options的判断:

if @ajax_options
  @ajax_options[:url] = url_options(page) if @ajax_options[:url].nil?
  @template.link_to_remote text, @ajax_options
else
  @template.link_to text, url_options(page)
end

源代码203行左右(因为上面加了几行,所以这里不准确,这里贴整段):

就是def url_options(page)这里:
def url_options(page)
  options = { param_name => page }
  # page links should preserve GET parameters
  options = params.merge(options) if @template.request.get?
  options.rec_merge!(@options[:params]) if @options[:params]
  options[:ajax] = true if !options.has_key?(:ajax) and !@ajax_options.nil?
  return options
end

嗯,如何调用呢?

<%= will_paginate @favorites, { :param_name => :fav_page }, { :update => "favorites_list", :method => "get" } %>

什么,这不就和link_remote_to差不多嘛,嗯,差不多就拿去用吧!HuHu~~

PS一下:这个方法还没彻底测试过,需要大家测试测试。



posted @ 2008-03-05 02:02 Janpoem 阅读(342) 评论(2) 编辑

导航

公告

统计