<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>lrbnew (mr liu)</title>
    <link>https://ruby-china.org/lrbnew</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Padrino 框架 attack prevented by Rack::Protection::AuthenticityToken</title>
      <description>&lt;p&gt;如题，用户退出功能，仿照了 ruby-china 的前端代码，&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;%=&lt;/span&gt; &lt;span class="na"&gt;link_to&lt;/span&gt; &lt;span class="na"&gt;t&lt;/span&gt;&lt;span class="err"&gt;('&lt;/span&gt;&lt;span class="na"&gt;user.sign_out&lt;/span&gt;&lt;span class="err"&gt;'),&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="na"&gt;:accounts&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;:destroy&lt;/span&gt;&lt;span class="err"&gt;),&lt;/span&gt; &lt;span class="na"&gt;:method =&lt;/span&gt;&lt;span class="err"&gt;&amp;gt; &lt;/span&gt;&lt;span class="s"&gt;"delete"&lt;/span&gt; &lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;引入了 jquery-ujs&lt;/p&gt;

&lt;p&gt;生成的 html 如下：&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;a&lt;/span&gt;  &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/sign_out"&lt;/span&gt; &lt;span class="na"&gt;data-method=&lt;/span&gt;&lt;span class="s"&gt;"delete"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"nofollow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;退出&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;页面点击退出时，显示 forbidden，后台的 log 提示 &lt;code&gt;attack prevented by Rack::Protection::AuthenticityToken&lt;/code&gt;
怀疑是和 csrf 有关，但是不知道怎么规避？ &lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Tue, 13 Oct 2015 23:17:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/27660</link>
      <guid>https://ruby-china.org/topics/27660</guid>
    </item>
    <item>
      <title>padrino 开发环境的局域网访问</title>
      <description>&lt;p&gt;如题，padrino 开发环境下，只能本机访问 localhost:3000，怎么实现局域网内其他机器通过 IP:3000 的方式来访问呢&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Thu, 01 Oct 2015 12:30:35 +0800</pubDate>
      <link>https://ruby-china.org/topics/27535</link>
      <guid>https://ruby-china.org/topics/27535</guid>
    </item>
    <item>
      <title>帮忙看一下代码哪里有问题</title>
      <description>&lt;p&gt;附代码如下&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'pry'&lt;/span&gt;
&lt;span class="n"&gt;nat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"nat_num"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_orig_s"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"OA-R-U4-01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_orig_d"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"AR-GROUP"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_orig_port"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"Any"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_trans_s"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"IFAR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_trans_d"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"Any"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_trans_port"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"Any"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_type"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"source_nat"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nat_valid_ip"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"10.235.151.185"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s_ip"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"10.237.195.225"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"d_ip"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"|10.237.190.32|10.237.190.33|10.237.190.57"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;split_dest_ip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="n"&gt;ips&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"d_ip"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"|"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;ips&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;nat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d_ip"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;nat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"d_ip"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;
    &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt;
    &lt;span class="nb"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pry&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;split_dest_ip&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;本意想按照"d_ip"元素来拆分 nat 变量，使其变成：
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"10.237.190.32"}
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"10.237.190.33"}
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"|10.237.190.57"}&lt;/p&gt;

&lt;p&gt;结果悲剧了，成了
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"|10.237.190.57"}
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"|10.237.190.57"}
{"nat_num"=&amp;gt;"1", "nat_orig_s"=&amp;gt;"OA-R-U4-01", "nat_orig_d"=&amp;gt;"AR-GROUP", "nat_orig_port"=&amp;gt;"Any", "nat_trans_s"=&amp;gt;"IFAR", "nat_trans_d"=&amp;gt;"Any", "nat_trans_port"=&amp;gt;"Any", "nat_type"=&amp;gt;"source_nat", "nat_valid_ip"=&amp;gt;"10.235.151.185", "s_ip"=&amp;gt;"10.237.195.225", "d_ip"=&amp;gt;"|10.237.190.57"}&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Sat, 18 Jul 2015 14:19:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/26550</link>
      <guid>https://ruby-china.org/topics/26550</guid>
    </item>
    <item>
      <title>ruby-china 用户 view 的一个问题请教</title>
      <description>&lt;p&gt;在 user 的 view 里面（user/show.html.erb)，有一个问题没有想明白&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= render "sidebar", user: @user %&amp;gt;
```erb

这里的 user: 是哪里定义的方法？
@user这个变量从哪里取值初始化的？
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <author>lrbnew</author>
      <pubDate>Sat, 27 Jun 2015 14:44:06 +0800</pubDate>
      <link>https://ruby-china.org/topics/26207</link>
      <guid>https://ruby-china.org/topics/26207</guid>
    </item>
    <item>
      <title>请教一下 ruby-china 的用户页面路由设置</title>
      <description>&lt;p&gt;例子，我的主页 &lt;a href="https://ruby-china.org/lrbnew" rel="nofollow" target="_blank"&gt;https://ruby-china.org/lrbnew&lt;/a&gt;  这样的路由形式在 routes 文件中怎么定义的？ &lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Sat, 27 Jun 2015 00:07:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/26201</link>
      <guid>https://ruby-china.org/topics/26201</guid>
    </item>
    <item>
      <title>关于 Devise 的 resource 问题</title>
      <description>&lt;p&gt;如题，在 rubychina 源码中，登录相关的 post 应该是发送到 session#create 吧，在这里有一段不太明白&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;
    &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;warden&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;authenticate!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;scope: &lt;/span&gt;&lt;span class="n"&gt;resource_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;recall: &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;controller_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;#new"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;set_flash_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:notice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:signed_in&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;is_navigational_format?&lt;/span&gt;
    &lt;span class="n"&gt;sign_in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resource_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ensure_private_token!&lt;/span&gt;
    &lt;span class="n"&gt;respond_to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;redirect_to&lt;/span&gt; &lt;span class="n"&gt;after_sign_in_path_for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="s1"&gt;'201'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;json: &lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;only: &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:login&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:private_token&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这里的  &lt;strong&gt;resource = warden.authenticate!(scope: resource_name, recall: "#{controller_path}#new") 该怎么理解？&lt;/strong&gt;&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Thu, 25 Jun 2015 22:27:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/26188</link>
      <guid>https://ruby-china.org/topics/26188</guid>
    </item>
    <item>
      <title>ruby-china 源码  如何设置登录后的默认首页为用户主页-</title>
      <description>&lt;p&gt;如题，登录前指向注册页面，登录后直接进入用户首页&lt;a href="https://ruby-china.org/lrbnew" rel="nofollow" target="_blank"&gt;https://ruby-china.org/lrbnew&lt;/a&gt;
已经修改 routes 文件，但是登录后进入用户首页如何写呢&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;devise_scope&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;authenticated&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt;  &lt;span class="no"&gt;XXXXX&lt;/span&gt; &lt;span class="ss"&gt;as: :authenticated_root&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="n"&gt;unauthenticated&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="s1"&gt;'sessions#new'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;as: :unauthenticated_root&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;除了修改 routes 文件，其他还有什么思路&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Thu, 25 Jun 2015 00:32:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/26169</link>
      <guid>https://ruby-china.org/topics/26169</guid>
    </item>
    <item>
      <title>cpanel  -&gt; topic 里面的 source 字段是做什么用的</title>
      <description>&lt;p&gt;在本地搭了环境，学习 ruby-china 的源码，在&lt;a href="http://0.0.0.0:3000/cpanel/topics/2/edit" rel="nofollow" target="_blank"&gt;http://0.0.0.0:3000/cpanel/topics/2/edit&lt;/a&gt; 报错了。
进一步检查发现在 cpanel  -&amp;gt; topic 的 view 里面（_form 模板内），有 source 字段，但是看 topic 的 model 设计，没有这个 source 啊。
这个 source 是做什么用的？&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Sun, 14 Jun 2015 18:03:47 +0800</pubDate>
      <link>https://ruby-china.org/topics/26013</link>
      <guid>https://ruby-china.org/topics/26013</guid>
    </item>
    <item>
      <title>ruby-china 不支持微信浏览器吗</title>
      <description>&lt;p&gt;如题，微信浏览器内页面显示一片橘红。其他什么都没有&lt;/p&gt;
&lt;h2 id="我微信6.1版。"&gt;我微信 6.1 版。&lt;/h2&gt;
&lt;p&gt;github 讨论了这个，但是没有效果啊，ios 的没有问题，安卓的不行
&lt;a href="https://github.com/ruby-china/ruby-china/issues/397" rel="nofollow" target="_blank"&gt;https://github.com/ruby-china/ruby-china/issues/397&lt;/a&gt;&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Sun, 17 May 2015 19:17:46 +0800</pubDate>
      <link>https://ruby-china.org/topics/25614</link>
      <guid>https://ruby-china.org/topics/25614</guid>
    </item>
    <item>
      <title>nokogiri 采集网页的乱码问题</title>
      <description>&lt;p&gt;今天采集网页内容，遇到乱码问题，这里讨论的很热烈&lt;a href="http://ruby-china.org/topics/2484" rel="nofollow" target="_blank"&gt;http://ruby-china.org/topics/2484&lt;/a&gt;，
但是原帖内容多且杂乱，看的费劲，这里把解决问题的几段贴出来，方便大家查找参考：&lt;/p&gt;
&lt;h2 id="@user1的办法1："&gt;
&lt;a href="/hooopo" class="user-mention" title="@hooopo"&gt;&lt;i&gt;@&lt;/i&gt;hooopo&lt;/a&gt;的办法 1：&lt;/h2&gt;
&lt;p&gt;html = open(url).read
html.force_encoding("gbk")
html.encode!("utf-8")
doc = Nokogiri::HTML.parse html
doc.css("body")&lt;/p&gt;
&lt;h2 id="@user2的办法2："&gt;
&lt;a href="/hooopo" class="user-mention" title="@hooopo"&gt;&lt;i&gt;@&lt;/i&gt;hooopo&lt;/a&gt;的办法 2：&lt;/h2&gt;
&lt;p&gt;html = open(url).read
html = Iconv.conv("utf-8", "gbk", html)
doc = Nokogiri::HTML.parse html
doc.css("body")&lt;/p&gt;

&lt;p&gt;需要注意，以上代码都是先转码，然后解析。最后，感谢 hooopo 的分享。&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Mon, 17 Feb 2014 17:29:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/17315</link>
      <guid>https://ruby-china.org/topics/17315</guid>
    </item>
    <item>
      <title>ActiveRecord 批量插入数据的性能问题</title>
      <description>&lt;p&gt;最近用 padrino 作点东西，开发环境下批量插入数据，特别慢，1000 条记录大概 1 分钟。
查看 debug 信息，发现 1000 条 insert 后面，带了 1000 个 commit；&lt;/p&gt;

&lt;p&gt;原因很明显，冗余 commit 带来的性能下降，所以，如果能实现多次 insert，一次 commit，应该能解决。&lt;/p&gt;

&lt;p&gt;自己是 ruby 新手，也没找到个解决办法，直到看见这个贴&lt;a href="http://ruby-china.org/topics/580" rel="nofollow" target="_blank"&gt;http://ruby-china.org/topics/580&lt;/a&gt;
里面&lt;a href="/yangyanhao" class="user-mention" title="@yangyanhao"&gt;&lt;i&gt;@&lt;/i&gt;yangyanhao&lt;/a&gt; 推荐的资料&lt;a href="https://www.coffeepowered.net/2009/01/23/mass-inserting-data-in-rails-without-killing-your-performance/" rel="nofollow" target="_blank"&gt;https://www.coffeepowered.net/2009/01/23/mass-inserting-data-in-rails-without-killing-your-performance/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;这个完美的解决了我的问题，从原来的 1 分钟入库，变成 1 秒钟入库！
debug 日志变成了 1000 个 insert 后面带一个 commit。&lt;/p&gt;

&lt;p&gt;附修改前入库代码
  CodeName.create &lt;a href="/carry" class="user-mention" title="@carry"&gt;&lt;i&gt;@&lt;/i&gt;carry&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;修改后入库代码
    ActiveRecord::Base.transaction do
       CodeName.create &lt;a href="/carry" class="user-mention" title="@carry"&gt;&lt;i&gt;@&lt;/i&gt;carry&lt;/a&gt;
    end&lt;/p&gt;</description>
      <author>lrbnew</author>
      <pubDate>Tue, 11 Feb 2014 11:40:11 +0800</pubDate>
      <link>https://ruby-china.org/topics/17163</link>
      <guid>https://ruby-china.org/topics/17163</guid>
    </item>
  </channel>
</rss>
