<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>sforce100 (sforce)</title>
    <link>https://ruby-china.org/sforce100</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>想问一下 mqtt 协议适合做 im 聊天的协议么？</title>
      <description>&lt;p&gt;我发现很多资料都是说 mqtt 做推送，还有就是订阅发布之类的。但是如果做即时通信聊天方面的适合么。还是说要做扩展？？
im 新手，求教&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Thu, 18 Dec 2014 20:02:20 +0800</pubDate>
      <link>https://ruby-china.org/topics/23271</link>
      <guid>https://ruby-china.org/topics/23271</guid>
    </item>
    <item>
      <title>微信网页授权失败的问题</title>
      <description>&lt;p&gt;使用了一下两个 gem 做微信的网页授权，&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'omniauth'
gem 'omniauth-weixin'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;奇怪的是当我点击回调的连接以后，微信向我服务器发送了三次回调，前两次连报错都没有，但是第三次是成功的。但最后微信页面上显示找不到页面。&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Mon, 16 Jun 2014 19:17:42 +0800</pubDate>
      <link>https://ruby-china.org/topics/19974</link>
      <guid>https://ruby-china.org/topics/19974</guid>
    </item>
    <item>
      <title>还是不太搞得懂 socket 里面得几个方法得区别</title>
      <description>&lt;p&gt;如题，还是不太搞的懂 socket 里面 read/write, gets/puts, send/recv这几个方法的区别？&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Sun, 18 May 2014 17:51:12 +0800</pubDate>
      <link>https://ruby-china.org/topics/19353</link>
      <guid>https://ruby-china.org/topics/19353</guid>
    </item>
    <item>
      <title>一个上传接口，接收 base64 解码出来不是一张图片</title>
      <description>&lt;p&gt;使用 CarrierWave 做一个上传图片的接口，要求客户端图片经过 base64 编码。&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:picture&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s2"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;picture_path_params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:picture&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;tempfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Tempfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fileupload"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;tempfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;binmode&lt;/span&gt;
  &lt;span class="n"&gt;tempfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;picture_path_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;

  &lt;span class="c1"&gt;#create a new uploaded file&lt;/span&gt;
  &lt;span class="n"&gt;uploaded_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ActionDispatch&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;UploadedFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:tempfile&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;tempfile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:filename&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;picture_path_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"filename"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="ss"&gt;:original_filename&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;picture_path_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"original_filename"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:picture&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="n"&gt;uploaded_file&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;uploader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ChatBase64Uploader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;
&lt;span class="n"&gt;uploader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;store!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:picture&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;我做了一个 java 的 demo，上传没问题。&lt;/p&gt;

&lt;p&gt;但是 ios 那边传过来的图片解码后总提示不是&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Failed&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;manipulate&lt;/span&gt; &lt;span class="n"&gt;with&lt;/span&gt; &lt;span class="no"&gt;MiniMagick&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maybe&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;image?&lt;/span&gt; &lt;span class="no"&gt;Original&lt;/span&gt; &lt;span class="no"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;Command&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"identify -quiet -ping /var/folders/8q/wwnwcmt93lvcynt9_5yjhqrr0000gn/T/mini_magick20140516-77009-1o5zyba.jpg_s"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ss"&gt;failed: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:status_code&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:output&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"identify: IHDR: CRC error `/var/folders/8q/wwnwcmt93lvcynt9_5yjhqrr0000gn/T/mini_magick20140516-77009-1o5zyba.jpg_s' @ error/png.c/MagickPNGErrorHandler/1806.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;identify: corrupt image `/var/folders/8q/wwnwcmt93lvcynt9_5yjhqrr0000gn/T/mini_magick20140516-77009-1o5zyba.jpg_s' @ error/png.c/ReadPNGImage/4077.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>sforce100</author>
      <pubDate>Sun, 18 May 2014 11:40:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/19340</link>
      <guid>https://ruby-china.org/topics/19340</guid>
    </item>
    <item>
      <title>关于加载 DelPhi7 写成的 dll 错误</title>
      <description>&lt;p&gt;如题，我想用 ruby 加载一个 DelPhi7 写成的 dll&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;）&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'dl'&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'dl/import'&lt;/span&gt;

&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;A&lt;/span&gt;
  &lt;span class="kp"&gt;extend&lt;/span&gt; &lt;span class="no"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Importer&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'fiddle'&lt;/span&gt;

&lt;span class="n"&gt;lib&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Fiddle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'btnetwork.dll'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;）&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'dl'&lt;/span&gt;
&lt;span class="no"&gt;DL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'btnetwork.dll'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;使用以上两种写法都一直报错&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;dll_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="ss"&gt;:in&lt;/span&gt; &lt;span class="sb"&gt;`initialize': dlopen(/btnetwork.dll, 9): no suitable image found.  Did find: (DL::DLError)
  /btnetwork.dll: unknown file type, first eight bytes: 0x4D 0x5A 0x50 0x00 0x02 0x00 0x00 0x00
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 22 Apr 2014 17:37:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/18775</link>
      <guid>https://ruby-china.org/topics/18775</guid>
    </item>
    <item>
      <title>关于字节处理</title>
      <description>&lt;p&gt;10 进制转成 16 进制字节，并不是单纯进制转换。
例如我想将 101 转成\x00\x65，应该如何处理呢？？看到文档说用 pack，我这样写 [101].pack('n*')，结果却是"\x00e"&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Fri, 18 Apr 2014 13:38:38 +0800</pubDate>
      <link>https://ruby-china.org/topics/18688</link>
      <guid>https://ruby-china.org/topics/18688</guid>
    </item>
    <item>
      <title>Sublime 到处配置方案么？？</title>
      <description>&lt;p&gt;如题，在一台机器上面配置好 sublime 的主题啊，安装好喜欢的插件啊，还有 tab 空几个空格之类的配置。不想再另外一台机器上用 sublime 又要配置多一次。能导出配置或把配置好的 sublime 打包么？？？&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Sat, 08 Feb 2014 09:47:54 +0800</pubDate>
      <link>https://ruby-china.org/topics/17110</link>
      <guid>https://ruby-china.org/topics/17110</guid>
    </item>
    <item>
      <title>unicorn 切换到 rainbows 出现问题</title>
      <description>&lt;p&gt;在 unicorn 上跑是正常的。rainbows 延用 unicorn 的配置，加上&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;worker_processes 4 
 Rainbows! do
   use :FiberSpawn
   worker_connections 20
 end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;rainbows.rb 的完整配置如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# -*- encoding: utf-8 -*-
module Rails
  class &amp;lt;&amp;lt;self
    def root
      File.expand_path(__FILE__).split('/')[0..-3].join('/')
    end
  end
end

rails_env = ENV["RAILS_ENV"] || "production"

   worker_processes 4 # assuming four CPU cores
    Rainbows! do
      use :FiberSpawn
      worker_connections 8
    end

preload_app true
working_directory Rails.root
pid "/tmp/rainbows.pid"
stderr_path "/tmp/log/rainbows.log"
stdout_path "/tmp/log/rainbows.log"

listen 3001, :tcp_nopush =&amp;gt; false

listen "/tmp/rainbows.xrk_crm.sock", backlog: 1024
#worker_processes 8
timeout 30

if GC.respond_to?(:copy_on_write_friendly=)
  GC.copy_on_write_friendly = true
end

before_exec do |server|
  ENV["BUNDLE_GEMFILE"] = "#{Rails.root}/Gemfile"
end

before_fork do |server, worker|
  old_pid = "#{Rails.root}/tmp/pids/rainbows.pid.oldbin"
  if File.exists?(old_pid) &amp;amp;&amp;amp; server.pid != old_pid
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      puts "Send 'QUIT' signal to rainbows error!"
    end
  end
end

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;启动命令：
bundle exec rainbows -c config/rainbows.rb -E staging -D&lt;/p&gt;

&lt;p&gt;进程是启动了。但访问的时候出现“ActionView::Template::Error (stack level too deep):
  /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:104”&lt;/p&gt;

&lt;p&gt;这是怎么回事呢&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Thu, 04 Jul 2013 11:29:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/12238</link>
      <guid>https://ruby-china.org/topics/12238</guid>
    </item>
    <item>
      <title>Rails 使用 Sysloglogger，无效</title>
      <description>&lt;p&gt;尝试了一下 logrogate+syslog_logger
使用 gem 'SyslogLogger', "1.4.0"&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;或&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.logger = SyslogLogger.new("your_app_name")
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是发现用上 syslog_logger 以后，控制台里面完全没 log 显示了。log 文件里面也没有内容。&lt;/p&gt;

&lt;p&gt;另外，logrogate 我这样配置&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/rails_apps/log_test/current/log/staging.log  {
        missingok
        nocompress
        daily
        copytruncate
        create
        ifempty
        rotate 3
        dateext
       olddir /tmp
        postrotate
                [ -f /opt/rails_apps/log_test/current/tmp/pids/unicorn.pid ] &amp;amp;&amp;amp; su hzh -c " kill -USR1 `cat /opt/rails_apps/log_test/current/tmp/pids/unicorn.pid`"
        endscript
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;logrotate 强制执行了一下，没在/tmp 目录下找到分割的日志&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Mon, 03 Jun 2013 09:59:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/11441</link>
      <guid>https://ruby-china.org/topics/11441</guid>
    </item>
    <item>
      <title>Refreshing Gem list 很久很久啊</title>
      <description>&lt;p&gt;生产环境部署。。使用 unicorn 和 capistrano。。但是 unicorn 启动实例时。。一直卡再 Refreshing Gem list。居然 10 多分钟？？
另外有方法禁止 Refreshing Gem list 吗&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Wed, 08 May 2013 12:41:31 +0800</pubDate>
      <link>https://ruby-china.org/topics/10814</link>
      <guid>https://ruby-china.org/topics/10814</guid>
    </item>
    <item>
      <title>ab/testing split</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/andrew/split" rel="nofollow" target="_blank"&gt;https://github.com/andrew/split&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;关于 AB 测试的一个 gem，一个 controller 代码如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def show
  @ab_style = ab_test("show_click", "origin", "testA")
end

def split_finish
  finished("show_click", :reset =&amp;gt; false)
  render :nothing =&amp;gt; true
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;官方描述 finished 方法中的 reset
Reset after completion
When a user completes a test their session is reset so that they may start the test again in the future.&lt;/p&gt;

&lt;p&gt;To stop this behaviour you can pass the following option to the finished method:&lt;/p&gt;

&lt;p&gt;finished('experiment_name', :reset =&amp;gt; false)
The user will then always see the alternative they started with.&lt;/p&gt;

&lt;p&gt;但是每当我请求 split_finish 以后，再次请求 show，又会获得新的值。&lt;/p&gt;

&lt;p&gt;split 里面的 ab_test 方法会 set 一个 user session，show action 以后：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"session":{"session_id":"....","_csrf_token":"....","split":{"show_click:6":"origin"},}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;finished 以后：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"session":{"session_id":"....","_csrf_token":".....","split":{},}}
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 09 Apr 2013 22:27:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/10052</link>
      <guid>https://ruby-china.org/topics/10052</guid>
    </item>
    <item>
      <title>view 下的 XXX.js.erb 文件..编译时会做什么处理吗</title>
      <description>&lt;p&gt;想用 kaminari 做异步分页...一下是个例子
&lt;a href="https://github.com/amatsuda/kaminari_example/blob/ajax/app/views/users/index.js.erb" rel="nofollow" target="_blank"&gt;https://github.com/amatsuda/kaminari_example/blob/ajax/app/views/users/index.js.erb&lt;/a&gt;
但是 view 下存在一个 index.js.erb...这个文件会被怎么处理呢。。。发布时 js 编译应该不会找到 view 下的 js 文件吧&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Sun, 07 Apr 2013 23:32:25 +0800</pubDate>
      <link>https://ruby-china.org/topics/10013</link>
      <guid>https://ruby-china.org/topics/10013</guid>
    </item>
    <item>
      <title>load 多个 routes 文件</title>
      <description>&lt;p&gt;现在我有前后台两个路由文件，rails 里面增加了加载路径，加载正常。但是，发现 rspec 里面 load   routes 文件，load 了两个，之后后面 load 的一个生效！！而 rails 是怎么处理多个 routes 文件的。&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load "#{Rails.root}/config/routes/admin.rb"
load "#{Rails.root}/config/routes.rb"
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>sforce100</author>
      <pubDate>Thu, 28 Mar 2013 09:52:48 +0800</pubDate>
      <link>https://ruby-china.org/topics/9800</link>
      <guid>https://ruby-china.org/topics/9800</guid>
    </item>
    <item>
      <title>关于重构，代码组织的疑问</title>
      <description>&lt;p&gt;近期看了下重构的资料，提到‘Skinny Controller, Fat Model’。
1.那么 model，controller 需要定义共用函数，有人就定义 concern model 来包裹共用函数。而 Rails 4 已经内建支持 Concern。
大家会这样用么？？？
2.假如 helper 里面需要定义共用函数呢？那么 mvc 都共用的函数呢？？该怎么组织比较好呢？？&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 19 Mar 2013 17:09:28 +0800</pubDate>
      <link>https://ruby-china.org/topics/9569</link>
      <guid>https://ruby-china.org/topics/9569</guid>
    </item>
    <item>
      <title>有用 swagger 写过 api 文档的吗</title>
      <description>&lt;p&gt;使用了 swagger-grape gem，用了 swagger-ui。想做到想 demo 里面可以显示描述的 status code 和 model。但是找了很久也找不到方法，另外尝试手动写个 static json 文件，但是 swagger-ui 怎么读这个 json 文件呢，直接访问也不行&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Sun, 17 Feb 2013 12:34:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/8717</link>
      <guid>https://ruby-china.org/topics/8717</guid>
    </item>
    <item>
      <title>有用 em-synchrony 的吗</title>
      <description>&lt;p&gt;启动时出现
[9965:INFO] 2013-02-06 16:49:21 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones./home/hzh/.rvm/gems/ruby-1.9.3-p194/gems/em-synchrony-1.0.3/lib/em-synchrony.rb:38: stack level too deep (SystemStackError)&lt;/p&gt;

&lt;p&gt;Fiber 超出 stack size？？？看 issue 好像说修复...怎么办呢 
ruby 版本 ruby-1.9.3-p194&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Wed, 06 Feb 2013 22:42:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/8633</link>
      <guid>https://ruby-china.org/topics/8633</guid>
    </item>
    <item>
      <title>关于 Marshal.dump 失败 no _dump_data is defined for class Proc</title>
      <description>&lt;p&gt;我有一个 Product 的 model，把他序列化 Marshal.dump(Product.new) 是可以的，
但是 p = Product.new 由于 model 的验证，p.save =&amp;gt; false。保存失败，然后我序列化这个 p,Marshal.dump(p) 就会报错 TypeError: no _dump_data is defined for class Proc&lt;/p&gt;

&lt;p&gt;1.9.3p194 :032 &amp;gt; p = Product.new
 =&amp;gt; # 
1.9.3p194 :033 &amp;gt; Marshal.dump(p)
 =&amp;gt; "\x04\bo:\fProduct\n:\x10@new_recordT:\x10@attributes{\vI\"\b_id\x06:\x06EFU:\x1AMoped::BSON::ObjectId\"\x11Q\x10\xD5\x8Fh\xE9\xF2\x15\x84\x00\x00\x06I\"\x15search_recommend\x06;\bFI\"\x00\x06;\bTI\"\x14questions_count\x06;\bFi\x00I\"\finsures\x06;\bF[\x00I\"\fpoperty\x06;\bFi\x06I\"\n_type\x06;\bFI\"\fProduct\x06;\bF:\x18@changed_attributes{\vI\"\b_id\x06;\bF0I\"\x15search_recommend\x06;\bF0I\"\x14questions_count\x06;\bF0I\"\finsures\x06;\bF0I\"\fpoperty\x06;\bF0I\"\n_type\x06;\bF0:\x14@pending_nested{\x00:\x17@pending_relations{\x00" 
1.9.3p194 :034 &amp;gt; p.save
 =&amp;gt; false 
1.9.3p194 :035 &amp;gt; Marshal.dump(p)
TypeError: no _dump_data is defined for class Proc&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 05 Feb 2013 17:49:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/8616</link>
      <guid>https://ruby-china.org/topics/8616</guid>
    </item>
    <item>
      <title>cache_action 样式都没了</title>
      <description>&lt;p&gt;class BookController &amp;lt; ApplicationController
  caches_action :show, :layout =&amp;gt; false
  cache_sweeper :book_sweeper, :only =&amp;gt; [:create, :update, :destroy]
  def show
  .....
  end
end&lt;/p&gt;

&lt;p&gt;development 下跑.....样式都不出来了
cache 的内容不是存到文件系统的 public 目录下的吗？我发现 caches_action 的内容都在 tmp 目录下了。&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 29 Jan 2013 10:44:43 +0800</pubDate>
      <link>https://ruby-china.org/topics/8455</link>
      <guid>https://ruby-china.org/topics/8455</guid>
    </item>
    <item>
      <title>突然链接失败</title>
      <description>&lt;blockquote&gt;
&lt;p&gt;mongo&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;MongoDB shell version: 2.0.4
connecting to: test
Mon Jan 21 10:08:16 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed&lt;/p&gt;

&lt;p&gt;log:mongod: symbol lookup error: mongod: undefined symbol: _ZN7pcrecpp2RE4InitEPKcPKNS_10RE_Options&lt;/p&gt;

&lt;p&gt;难道只有重装啦？&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Mon, 21 Jan 2013 10:15:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/8219</link>
      <guid>https://ruby-china.org/topics/8219</guid>
    </item>
    <item>
      <title>关于 cache，加载 sweeper 报错</title>
      <description>&lt;p&gt;用 Page Cache 
增加了 app/sweepers/user_sweeper.rb
配置 environment.rb
Substation::Application.initialize!&lt;/p&gt;

&lt;p&gt;Rails::Initializer.run do |config|
  config.load_paths += %w(#{RAILS_ROOT}/app/sweepers)
end&lt;/p&gt;

&lt;p&gt;重起的是后报错&lt;/p&gt;

&lt;p&gt;/home/s f/rubyonrails/substation/config/environment.rb:7:in `': uninitialized constant Rails::Initializer (NameError)&lt;/p&gt;</description>
      <author>sforce100</author>
      <pubDate>Tue, 15 Jan 2013 16:05:58 +0800</pubDate>
      <link>https://ruby-china.org/topics/8091</link>
      <guid>https://ruby-china.org/topics/8091</guid>
    </item>
  </channel>
</rss>
