就是管理后台吧? 我也一直在寻找,依然没找到
ActiveAdmin 的分子里面貌似有可用的,不过有些 Bug
当你需要这样调用方法的时候
def foo
end
foo { "this is block param." }
现实点的场景,比如你需要给 Views 定一个 space_less Helper 方法,清除区域内的 HTML 的空白字符,使得调用起来可以这样:
<%= spaceless do %>
<html>
<body>
<head></head>
</body>
<% end %>
这个时候,你就需要用 yield 来定义一个可以接收 block 作为参数的方法了
module ApplicationHelper
def splace_less
body = yield
body.gsub!(/\s+/,'')
body
end
end
赶紧把 @ 回复通知的功能,搞到这个里面来
以前的数据没了啊?
Gemfile:
gem "omniauth-douban", :git => "git://github.com/ballantyne/omniauth-douban.git"
此外,现在用户信息去掉了之前姓名的项,只保留用户名,以简化,建议大家将用户名改为 Twitter ID,以便于 @ 回复的时候可以链接到 Twitter
论坛里面的格式化如果改为 markdown 不知大家觉得如何,但我又担心格式多了会太乱
其实现在的节点分得还不太好,没必要写 Rails 出来
Shit Rais 3.1 的 auto_link 依然有中文的 Bug
class Formatter
def self.markdown(str)
end
end
然后在 config/application.rb 里面
require "formatter"
以后任意地方就可以用:
Formatter.markdown
但是实际项目中效果不好,看数据
1.9.3-p0 的: Started GET "/topics" Completed 200 OK in 185ms (Views: 160.3ms | Mongo: 22.2ms)
Started GET "/wiki" Completed 200 OK in 52ms (Views: 48.7ms | Mongo: 2.3ms)
Started GET "/topics/6" Completed 200 OK in 116ms (Views: 90.7ms | Mongo: 19.7ms)
1.9.2 打过补丁的: Started GET "/topics" Completed 200 OK in 79ms (Views: 58.7ms | Mongo: 18.6ms)
Started GET "/wiki" Completed 200 OK in 18ms (Views: 15.7ms | Mongo: 1.8ms)
Started GET "/topics/6" Completed 200 OK in 65ms (Views: 48.4ms | Mongo: 10.0ms)
patchlevel: 334, release_date: 2011-02-18, ruby_version: 1.8.7, ruby_platform: i686-darwin11.1.0
********************************************************************************
user system total real
Date.today 9.060000 0.010000 9.070000 ( 9.095868)
Date.new 12.890000 0.060000 12.950000 ( 13.964456)
Array append 0.310000 0.000000 0.310000 ( 0.314164)
Regexp match 0.810000 0.000000 0.810000 ( 0.826616)
Random 0.100000 0.000000 0.100000 ( 0.100246)
Array index 0.440000 0.000000 0.440000 ( 0.483725)
Array flat 2.530000 0.030000 2.560000 ( 2.681633)
Class.new 0.190000 0.000000 0.190000 ( 0.197483)
patchlevel: 0, release_date: 2011-10-30, ruby_version: 1.9.3, ruby_platform: x86_64-darwin11.2.0
********************************************************************************
user system total real
Date.today 0.700000 0.000000 0.700000 ( 0.704521)
Date.new 0.480000 0.010000 0.490000 ( 0.482028)
Array append 0.090000 0.000000 0.090000 ( 0.095969)
Regexp match 0.890000 0.000000 0.890000 ( 0.890583)
Random 0.130000 0.000000 0.130000 ( 0.133199)
Array index 0.350000 0.000000 0.350000 ( 0.356596)
Array flat 1.480000 0.000000 1.480000 ( 1.489049)
Class.new 0.120000 0.000000 0.120000 ( 0.133629)
patchlevel: 290, release_date: 2011-07-09, ruby_version: 1.9.2, ruby_platform: x86_64-darwin11.0.0
********************************************************************************
user system total real
Date.today 3.840000 0.020000 3.860000 ( 4.124494)
Date.new 3.220000 0.010000 3.230000 ( 3.393119)
Array append 0.080000 0.000000 0.080000 ( 0.085052)
Regexp match 1.030000 0.010000 1.040000 ( 1.053746)
Random 0.090000 0.000000 0.090000 ( 0.092339)
Array index 0.390000 0.000000 0.390000 ( 0.398123)
Array flat 1.390000 0.040000 1.430000 ( 1.479191)
Class.new 0.130000 0.000000 0.130000 ( 0.125919)
简单的测试:
./script/rails runner "puts 37337"
1.9.2-p290 ---- 16.92s user 1.43s system 69% cpu 26.423 total
ree-2011.03 ---- 11.46s user 1.23s system 70% cpu 17.955 total
1.9.3-p0 ---- 7.23s user 0.59s system 98% cpu 7.942 total
估计明天网上就会有性能报告出来了,大家拭目以待
很明显的就是 Date 的效率,现在改用 C 来实现的
刚才检测出 Mongoid::Versioning 的问题,这玩意儿默认情况下 Page.find(1) 这样查询会将 versions 数据也一并从 MongoDb 里面拉出来,所以导致了 Wiki 页面大内容的载入缓慢。 我暂时去掉了
这个事情不容易啊,镜像很大
我们可以聚合,然后后台选择性发布
可以啊