<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>xautjzd (xautjzd)</title>
    <link>https://ruby-china.org/xautjzd</link>
    <description>You will be what you want to be</description>
    <language>en-us</language>
    <item>
      <title>Ruby 实现的机器学习库有哪些？</title>
      <description>&lt;p&gt;最近打算了解下 &lt;strong&gt;Machine Learning&lt;/strong&gt;  相关的知识，可能主要涉及多媒体广告的 &lt;strong&gt;pCTR&lt;/strong&gt; （predicting Click-through Rate）。采用的算法可能先准备从 BP 或者 Logical Regression 着手，不知道有没有相关的库可供推荐下呢？目前发现一个 Logical Regression 的：&lt;a href="https://github.com/kei500/liblinear-ruby" rel="nofollow" target="_blank"&gt;https://github.com/kei500/liblinear-ruby&lt;/a&gt;。不过感觉不太好。&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sat, 18 Oct 2014 11:18:18 +0800</pubDate>
      <link>https://ruby-china.org/topics/22103</link>
      <guid>https://ruby-china.org/topics/22103</guid>
    </item>
    <item>
      <title>这句 ruby 脚本何解</title>
      <description>&lt;p&gt;刚才无意浏览到一个获取 web 页面的 urls 脚本：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;ruby&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ne&lt;/span&gt; &lt;span class="s1"&gt;'if $_ =~ /href=\"([^\"]+)\"/;puts $1;end'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;YourHTMLfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;html&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;请问，其中$1指的是哪个参数呢？其中那个正则看了半天也没看明白，三个&lt;code&gt;"&lt;/code&gt;照理应该是就近匹配原则&lt;/p&gt;

&lt;p&gt;如果不理解&lt;code&gt;$_&lt;/code&gt;全局变量，请参考：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/ruby/ruby/blob/trunk/lib/English.rb" rel="nofollow" target="_blank"&gt;https://github.com/ruby/ruby/blob/trunk/lib/English.rb&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/14177016/how-do-you-pipe-shell-output-to-ruby-e" rel="nofollow" target="_blank"&gt;http://stackoverflow.com/questions/14177016/how-do-you-pipe-shell-output-to-ruby-e&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 18 Aug 2014 21:38:11 +0800</pubDate>
      <link>https://ruby-china.org/topics/21100</link>
      <guid>https://ruby-china.org/topics/21100</guid>
    </item>
    <item>
      <title>Ruby 如何来实现 WebService 功能？</title>
      <description>&lt;p&gt;有这么一个需求：需要安卓程序里通过 WebService 来调用 Ruby 实现的某个功能，有没有类似的用 Ruby 实现的 WebService Server 呢？网上搜过，看到过&lt;a href="http://www.tutorialspoint.com/ruby/ruby_web_services.htm" rel="nofollow" target="_blank" title=""&gt;soap4r&lt;/a&gt;，不过太老了，gems 都找不到了。后来又找到了一个&lt;a href="https://github.com/savonrb/savon" rel="nofollow" target="_blank" title=""&gt;savon&lt;/a&gt;，不过是 Client，不是 Server。有什么好的解决方法能解决？希望能指点下&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Thu, 07 Aug 2014 22:15:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/20898</link>
      <guid>https://ruby-china.org/topics/20898</guid>
    </item>
    <item>
      <title>全局变量 $LOAD_PATH 如何理解</title>
      <description>&lt;p&gt;已经多次看到过全局变量$LOAD_PATH 了，只是大概知道作用是如果需要引用 library 时，会将其路径添加到 LOAD_PATH 中，这样在调用 library 中的类时，便能找到，否则会给出不识别类，找不到等错误提示。至于如何深层次理解，还是没搞明白，也尝试找了答案，但是没找到。只能发动求助技能了&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Tue, 27 May 2014 11:10:28 +0800</pubDate>
      <link>https://ruby-china.org/topics/19558</link>
      <guid>https://ruby-china.org/topics/19558</guid>
    </item>
    <item>
      <title>Markdown 解析过程中语法高亮问题</title>
      <description>&lt;p&gt;最近突然了解到 markdown 的解析器及语法高亮开源项目，便尝试自己来解析 markdown 文件，以下是我的源码：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env ruby&lt;/span&gt;

&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'redcarpet'&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'rouge'&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'rouge/plugins/redcarpet'&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HTML&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;Redcarpet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Render&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;HTML&lt;/span&gt;
    &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Rouge&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Plugins&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Redcarpet&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;render_options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="ss"&gt;filter_html:     &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# will insert &amp;lt;br /&amp;gt; tags in paragraphs where are newlines &lt;/span&gt;
    &lt;span class="c1"&gt;# (ignored by default)&lt;/span&gt;
    &lt;span class="ss"&gt;hard_wrap:       &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="c1"&gt;# hash for extra link options, for example 'nofollow'&lt;/span&gt;
    &lt;span class="ss"&gt;link_attributes: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;rel: &lt;/span&gt;&lt;span class="s1"&gt;'nofollow'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# renderer = Redcarpet::Render::HTML.new(render_options)&lt;/span&gt;
&lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HTML&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="n"&gt;render_options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;markdown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Redcarpet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Markdown&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="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;fenced_code_blocks: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;autolink: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get markdown file name to parse to html&lt;/span&gt;
&lt;span class="n"&gt;origin_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="c1"&gt;# Create xxx.html(origin file: xxx.markdown)&lt;/span&gt;
&lt;span class="n"&gt;des_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;origin_name&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="o"&gt;+&lt;/span&gt;&lt;span class="s2"&gt;".html"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;head&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8'&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;/head&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;body&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Parse markdown to html&lt;/span&gt;
&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;origin_name&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;line&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;des_file&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="n"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;/body&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;des_file&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="s2"&gt;"&amp;lt;/html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;执行这个脚本时，&lt;code&gt;ruby myscript.rb xxx.markdown&lt;/code&gt;，需要给脚本传一个待解析的 markdown 文本参数。markdown 里有以下的代码块：&lt;/p&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;fp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;proclnk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="cp"&gt;# test.txt为已存在的文件
&lt;/span&gt;    &lt;span class="n"&gt;fp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"test.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"r"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fp&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fileno&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;proclnk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"/proc/self/fd/%d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;readlink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;proclnk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"fp-&amp;gt;fd-&amp;gt;filepath: %p-&amp;gt;%d-&amp;gt;%s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但最后解析时，其他的 markdown 都能正确解析出来，惟独这个代码块解析有问题，一是没有语法高亮，二是&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;最后被解析成&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;include &amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;include &amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;请问有人碰到过这个问题么&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sun, 25 May 2014 15:51:06 +0800</pubDate>
      <link>https://ruby-china.org/topics/19523</link>
      <guid>https://ruby-china.org/topics/19523</guid>
    </item>
    <item>
      <title>一表关联多个外键的问题</title>
      <description>&lt;p&gt;业务情况大致如下：
一个 model 有两个字段都是另一个名为 dropdownlist 的 model 的外键，定义如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;belongs_to :dropdownlist, foreign_key: 'birth_place'
belongs_to :dropdownlsit, foreign_key: 'residence'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但&lt;code&gt;db:migrate&lt;/code&gt;后并没有在数据库对应表中生成 birth_place 和 residence 这两个字段，请大家给予指点。网上找了答案说是要 AddxxxRefToXXX，但是貌似这样不能自定义外键的名字&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 05 May 2014 17:08:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/19030</link>
      <guid>https://ruby-china.org/topics/19030</guid>
    </item>
    <item>
      <title>Asset Pipeline 会存在资源冲突和效率问题么</title>
      <description>&lt;p&gt;刚了解了 Asset Pipeline 的机制，发现会自动将 app/assets 下所有的 js 和 css 分别整合到一个 application.js 和 application.css，那么这样会不会 js 间产生冲突问题？如果某些页面只需要单纯的几个 js 文件，而采用 asset pipeline 将一个大的 application 加载，会不会有效率的问题？&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Fri, 02 May 2014 09:11:36 +0800</pubDate>
      <link>https://ruby-china.org/topics/18960</link>
      <guid>https://ruby-china.org/topics/18960</guid>
    </item>
    <item>
      <title>Rails 4 下 JS 与 CSS 引用问题</title>
      <description>&lt;p&gt;用的环境是 Rails4, 已经将要引用的 js 与 css 分别放置到 app/assets/javascripts/ 与 app/assets/stylesheets/目录下，并且已经在 application.js 与 application.css 中 require 过，用&lt;code&gt;stylesheet_link_tag&lt;/code&gt;和&lt;code&gt;javascript_include_tag&lt;/code&gt;在 View 文件中引用。运行程序后，出现：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( bootstrap.css )` to `config/initializers/assets.rb` and restart your server
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;网上找了好久，没找到解决办法，如果按照上面的提示添加的话，出现的效果与预期引用的 js 和 css 效果不符，同时 config/initialzers 目录下也没有 assets.rb 文件，冒然添加不知道会不会不妥。请大家帮忙指点下&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Wed, 30 Apr 2014 14:45:31 +0800</pubDate>
      <link>https://ruby-china.org/topics/18936</link>
      <guid>https://ruby-china.org/topics/18936</guid>
    </item>
    <item>
      <title>select distinct column_name from table_name 获取的每个元素为什么类型为 Hash 而不是 String</title>
      <description>&lt;p&gt;用 Ruby 脚本连接 MySQL 时，碰到如下问题：
执行&lt;code&gt;select distinct column_name from table_name&lt;/code&gt; 后，遍历前面的结果，发现每个元素的类型是 Hash，而不是 String。比如说列名为&lt;code&gt;Person&lt;/code&gt;，那么最后遍历出来的结果是：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"Person"=&amp;gt;"name-1"}
{"Person"=&amp;gt;"name-2"}
...
{"Person"=&amp;gt;"name-n"}
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>xautjzd</author>
      <pubDate>Fri, 25 Apr 2014 11:27:30 +0800</pubDate>
      <link>https://ruby-china.org/topics/18845</link>
      <guid>https://ruby-china.org/topics/18845</guid>
    </item>
    <item>
      <title>[已解决] 部署完成后，访问网站无法加载 css 和 javascripts</title>
      <description>&lt;p&gt;部署的系统为网上成熟的系统，以开发环境在本地跑完全没问题，但部署成功后，访问时发现无法加载 css 和 javascripts，但是功能正常。请问这可能是什么原因？应该如何解决？&lt;/p&gt;

&lt;p&gt;下面来张截图：
&lt;img src="//l.ruby-china.com/photo/2014/c22b08815460b3bc272390f32b3fd709.jpg" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;部署好的网址：&lt;a href="www.bebety.com" title=""&gt;www.bebety.com&lt;/a&gt;&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 21 Apr 2014 23:51:46 +0800</pubDate>
      <link>https://ruby-china.org/topics/18757</link>
      <guid>https://ruby-china.org/topics/18757</guid>
    </item>
    <item>
      <title>部署完成后访问出现：We're sorry, but something went wrong</title>
      <description>&lt;p&gt;&lt;strong&gt;背景&lt;/strong&gt;
开始在 CentOS 下部署，最终还是没法成功，便把环境切换到到 &lt;strong&gt;Ubuntu12.04 LTS&lt;/strong&gt; 64 位，开始使用 root 安装 RVM，Ruby 等环境，但是发现每次切换到一般用户下还是无法找到 Ruby，即使将相应脚本添加到~/.bashrc 下也不行。最后还是切换到一般用户下进行。部署完成后，访问出现 403 ForBidden，但是最后将/etc/nginx/nginx.conf 下的 user 改成了与 Rails app 目录一样的用户就顺利解决。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;问题&lt;/strong&gt;
ForBidden 问题解决后，但是再次访问便出现：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;We're sorry, but something went wrong
If you are the application owner check the logs for more information
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;查看 error.log 文件后还是没看明白到底怎么回事，error.log 文件信息如下：&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;error.log&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2014/04/21 09:58:48 [info] 573#0: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:74
[ 2014-04-21 09:58:48.3969 574/7f34ede5c740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' =&amp;gt; 'nobody', 'default_group' =&amp;gt; 'nogroup', 'default_python' =&amp;gt; 'python', 'default_ruby' =&amp;gt; 'ruby', 'default_user' =&amp;gt; 'nobody', 'log_level' =&amp;gt; '0', 'max_pool_size' =&amp;gt; '6', 'passenger_root' =&amp;gt; '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini', 'passenger_version' =&amp;gt; '4.0.41', 'pool_idle_time' =&amp;gt; '300', 'temp_dir' =&amp;gt; '/tmp', 'union_station_gateway_address' =&amp;gt; 'gateway.unionstationapp.com', 'union_station_gateway_port' =&amp;gt; '443', 'user_switching' =&amp;gt; 'true', 'web_server_passenger_version' =&amp;gt; '4.0.41', 'web_server_pid' =&amp;gt; '573', 'web_server_type' =&amp;gt; 'nginx', 'web_server_worker_gid' =&amp;gt; '1001', 'web_server_worker_uid' =&amp;gt; '1000' }
[ 2014-04-21 09:58:48.4022 577/7fce99aab740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.573/generation-0/request
[ 2014-04-21 09:58:48.4119 582/7fcbcd884740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.573/generation-0/logging
[ 2014-04-21 09:58:48.4153 574/7f34ede5c740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2014-04-21 09:58:48.4267 582/7fcbcd884740 agents/LoggingAgent/Main.cpp:289 ]: Caught signal, exiting...
[ 2014-04-21 09:58:49.4683 620/7f4c97015740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' =&amp;gt; 'nobody', 'default_group' =&amp;gt; 'nogroup', 'default_python' =&amp;gt; 'python', 'default_ruby' =&amp;gt; 'ruby', 'default_user' =&amp;gt; 'nobody', 'log_level' =&amp;gt; '0', 'max_pool_size' =&amp;gt; '6', 'passenger_root' =&amp;gt; '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini', 'passenger_version' =&amp;gt; '4.0.41', 'pool_idle_time' =&amp;gt; '300', 'temp_dir' =&amp;gt; '/tmp', 'union_station_gateway_address' =&amp;gt; 'gateway.unionstationapp.com', 'union_station_gateway_port' =&amp;gt; '443', 'user_switching' =&amp;gt; 'true', 'web_server_passenger_version' =&amp;gt; '4.0.41', 'web_server_pid' =&amp;gt; '619', 'web_server_type' =&amp;gt; 'nginx', 'web_server_worker_gid' =&amp;gt; '1001', 'web_server_worker_uid' =&amp;gt; '1000' }
[ 2014-04-21 09:58:49.4738 623/7fd1e0cab740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.619/generation-0/request
[ 2014-04-21 09:58:49.4829 628/7fd04aabf740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.619/generation-0/logging
[ 2014-04-21 09:58:49.4898 620/7f4c97015740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
App 657 stdout:
App 657 stderr: Instance method "open" is already defined in Object, use generic helper instead or set StateMachine::Machine.ignore_method_conflicts = true.
App 657 stderr:
[ 2014-04-21 09:59:05.3109 623/7fd1e0bb3700 Pool2/SmartSpawner.h:301 ]: Preloader for /var/www/bebety.com/current started on PID 657, listening on unix:/tmp/passenger.1.0.619/generation-0/backends/preloader.657
App 806 stdout:
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 21 Apr 2014 10:13:10 +0800</pubDate>
      <link>https://ruby-china.org/topics/18742</link>
      <guid>https://ruby-china.org/topics/18742</guid>
    </item>
    <item>
      <title>部署完成后访问 403 Forbidden</title>
      <description>&lt;p&gt;终于算是走完部署流程了，但重新启动 Nginx 时出现如下警告：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable (/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable. (-1: Unknown error)
Stopping nginx:                                            [  OK  ]
Starting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable (/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable. (-1: Unknown error)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;虽然有警告，但是 Nginx 服务已经启动，通过&lt;code&gt;netstat -anlp|grep 80&lt;/code&gt;可以查看到结果：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4574/nginx          
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      4574/nginx    
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;接着访问时出现 403 Forbidden 错误。网上可能是由于不允许访问目录导致的，但我参考的是 ruby-china 的&lt;a href="https://github.com/ruby-china/wiki/wiki/Ubuntu-12.04-%E4%B8%8A%E4%BD%BF%E7%94%A8-Nginx-Passenger-%E9%83%A8%E7%BD%B2-Ruby-on-Rails" rel="nofollow" target="_blank" title=""&gt;wiki&lt;/a&gt;,应该不会有问题。实在想不出来哪个环节出问题，大家帮忙瞧瞧？&lt;/p&gt;

&lt;p&gt;系统环境是 &lt;strong&gt;CentOS6.4&lt;/strong&gt;, 通过 yum 安装的 passenger，参考的是 passenger 的官方文档：&lt;a href="http://www.modrails.com/documentation/Users%20guide%20Nginx.htmlpassenger3,%E4%BD%86%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C" rel="nofollow" target="_blank"&gt;http://www.modrails.com/documentation/Users%20guide%20Nginx.htmlpassenger3,但安装完成后，&lt;/a&gt;，默认安装的是 /etc/nginx/conf.d/passenger.conf文件中passenger_root的默认路径为&lt;code&gt;/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12&lt;/code&gt;, 但进入这个目录看，发现里面也有&lt;code&gt;passenger-4.0.41&lt;/code&gt;，开始使用 3 不行，换成 4 也不行。在其中将 passenger_ruby 改为系统安装的&lt;code&gt;ruby2.0.0&lt;/code&gt;版本路径。&lt;/p&gt;

&lt;p&gt;请问这大概是什么问题？&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;测试网址&lt;/strong&gt;: &lt;a href="http://www.bebety.com" rel="nofollow" target="_blank" title=""&gt;www.bebety.com&lt;/a&gt;&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sun, 20 Apr 2014 16:10:38 +0800</pubDate>
      <link>https://ruby-china.org/topics/18736</link>
      <guid>https://ruby-china.org/topics/18736</guid>
    </item>
    <item>
      <title>passenger-install-nginx 编译 Nginx 出错</title>
      <description>&lt;p&gt;执行&lt;code&gt;passenger-instal-nginx&lt;/code&gt;进行 nginx 的编译，走到最后的编译阶段，结果出现如下错误：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward/hash_map:60,
                 from ext/common/Utils/HashMap.h:46,
                 from ext/common/Utils/StringMap.h:33,
                 from ext/common/Utils/CachedFileStat.hpp:42,
                 from ext/common/ApplicationPool2/AppTypes.h:81,
                 from ext/common/ApplicationPool2/Options.h:32,
                 from ext/common/ApplicationPool2/Common.h:32,
                 from ext/common/ApplicationPool2/Pool.h:43,
                 from ext/common/ApplicationPool2/Implementation.cpp:31:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
c++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See &amp;lt;http://bugzilla.redhat.com/bugzilla&amp;gt; for instructions.
rake aborted!
Command failed with status (1): [c++ -Iext -Iext/common -Iext/libev  -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -fcommon -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAVE_ACCEPT4 -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="&amp;lt;hash_map&amp;gt;" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="&amp;lt;hash_fun.h&amp;gt;" -o buildout/common/libpassenger_common/ApplicationPool2/Implementation.o -c ext/common/ApplicationPool2/Implementation.cpp]
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.41/build/cplusplus_support.rb:51:in `run_compiler'
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.41/build/cplusplus_support.rb:61:in `compile_cxx'
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.41/lib/phusion_passenger/common_library.rb:133:in `block (2 levels) in define_category_tasks'
Tasks: TOP =&amp;gt; nginx =&amp;gt; nginx_without_native_support =&amp;gt; buildout/agents/PassengerHelperAgent =&amp;gt; buildout/common/libpassenger_common/ApplicationPool2/Implementation.o
(See full trace by running task with --trace)
--------------------------------------------

It looks like something went wrong

Please read our Users guide for troubleshooting tips:

   /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.41/doc/Users guide Nginx.html
   http://www.modrails.com/documentation/Users%20guide%20Nginx.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;看了上面的报错信息，但是还是无法找出原因，大家帮忙看看吧&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sun, 20 Apr 2014 14:22:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/18731</link>
      <guid>https://ruby-china.org/topics/18731</guid>
    </item>
    <item>
      <title>Gemfile syntax error compile error on line 19: syntax error, unexpected ':', expecting $end gem 'therubyracer', platforms: :ruby ^ (Bundler::GemfileError)</title>
      <description>&lt;p&gt;部署完成后，访问主页，出现如题的错误：&lt;code&gt;Gemfile syntax error compile error on line 19: syntax error, unexpected ':', expecting $end gem 'therubyracer', platforms: :ruby ^ (Bundler::GemfileError)&lt;/code&gt;.但是 Gemfile 中：&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gem 'therubyracer', platforms: :ruby&lt;/code&gt; 是自动生成，只是去掉注释而已，这是什么原因？&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sun, 20 Apr 2014 10:15:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/18723</link>
      <guid>https://ruby-china.org/topics/18723</guid>
    </item>
    <item>
      <title>最低配最傻瓜式的部署需要准备哪些东西？</title>
      <description>&lt;p&gt;第一次部署 Rails app 应用，请问需要哪些东西，参考过网上的博客，有提到 Unicorn, Nginx，Apache，Capitrano,Mina...那么最低配最傻瓜式的搭配是什么呢？对性能没有什么要求，纯粹熟悉部署过程。&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sat, 19 Apr 2014 20:07:47 +0800</pubDate>
      <link>https://ruby-china.org/topics/18715</link>
      <guid>https://ruby-china.org/topics/18715</guid>
    </item>
    <item>
      <title>部署 Rails app，需要本地的版本与服务器一致不？</title>
      <description>&lt;p&gt;同学准备做外贸，需要一个商品展示的网站，找我帮忙，我便网上找了一个开源免费的产品 &lt;strong&gt;&lt;a href="http://spreecommerce.com/" rel="nofollow" target="_blank" title=""&gt;Spree&lt;/a&gt;&lt;/strong&gt;，然后买了一个月的阿里云，想先练练手，看能不能将 Spree 部署上去。部署工具采用的是 &lt;strong&gt;Mina&lt;/strong&gt;，但本地生成 app 的 ruby 版本是 1.9.3，而 vps 上安装的是 2.0.0,rails 都是 4.0.4 版 (Spree 文档要求安装的 4.0.4)，不知道这样版本不同可以部署上去不？在部署的过程中执行&lt;code&gt;mina setup&lt;/code&gt;时一直卡在那，没有任何提示，不知道何缘故，以为是 ssh 连不上，但采用 ssh 连接 vps，没问题。请问这会是版本不一致导致的原因么？&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sat, 19 Apr 2014 12:48:19 +0800</pubDate>
      <link>https://ruby-china.org/topics/18709</link>
      <guid>https://ruby-china.org/topics/18709</guid>
    </item>
    <item>
      <title>求一款在 Vim 下预览 Markdown 的插件</title>
      <description>&lt;p&gt;如题，哪位朋友能够推荐一款能够在 Linux 平台下预览 markdown 的插件呢？没有预览功能，写 markdown 真蛋疼，每次都得多提交好几次。&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Sat, 15 Mar 2014 23:00:15 +0800</pubDate>
      <link>https://ruby-china.org/topics/17911</link>
      <guid>https://ruby-china.org/topics/17911</guid>
    </item>
    <item>
      <title>寻求用 Markdown 语法制作 PPT 的工具</title>
      <description>&lt;p&gt;以前见过有人用 markdown 语法来制作 PPT，但一直不知道采用的是何种工具，近几天轮到自己做 PPT 了，又不想麻烦的自己布局，找背景、调样式等，所以想寻求一款通过 markdown 语法来制作 PPT 的工具，希望能给予建议。最好能是 vim 或者 sublime 的什么插件之类。网上也找到了一款：&lt;a href="http://js8.in/2013/11/16/%E6%8E%A8%E8%8D%90nodeppt%EF%BC%9A%E4%BD%BF%E7%94%A8markdown%E8%AF%AD%E6%B3%95%E6%9D%A5%E5%86%99%E7%BD%91%E9%A1%B5ppt/" rel="nofollow" target="_blank"&gt;http://js8.in/2013/11/16/%E6%8E%A8%E8%8D%90nodeppt%EF%BC%9A%E4%BD%BF%E7%94%A8markdown%E8%AF%AD%E6%B3%95%E6%9D%A5%E5%86%99%E7%BD%91%E9%A1%B5ppt/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;但总感觉效果不是很好，希望能找到一个更好的&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 10 Mar 2014 18:55:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/17788</link>
      <guid>https://ruby-china.org/topics/17788</guid>
    </item>
    <item>
      <title>Ruby 官方介绍——Ruby 表达的一致性怎么解释？</title>
      <description>&lt;p&gt;身为高年级的学生党，应学校某青年教师之邀给几个低年级的学生介绍 Ruby。免不了去官网上找点介绍性的资料，开头的介绍文字不是很理解。其中 &lt;strong&gt;表达的一致性&lt;/strong&gt; 怎么解释呢？原文如下：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ruby 是...&lt;/strong&gt;
一种跨平台、面向对象的动态类型编程语言。Ruby 体现了表达的一致性和简单性，它不仅是一门编程语言，更是表达想法的一种简练方式。&lt;/p&gt;
&lt;/blockquote&gt;</description>
      <author>xautjzd</author>
      <pubDate>Thu, 27 Feb 2014 12:41:54 +0800</pubDate>
      <link>https://ruby-china.org/topics/17525</link>
      <guid>https://ruby-china.org/topics/17525</guid>
    </item>
    <item>
      <title>Vim 的 TagBar/TagList 如何跳转到系统库函数？</title>
      <description>&lt;p&gt;最近开始阅读 thin 的源码，其中包含有 TCPServer 类，于是乎想查看其定义，但是通过 Tagbar/TagList 无法跳转过去，因为找不到 tags。如果我想在 Vim 中查看其定义，该怎么办呢&lt;/p&gt;</description>
      <author>xautjzd</author>
      <pubDate>Mon, 20 Jan 2014 13:30:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/16887</link>
      <guid>https://ruby-china.org/topics/16887</guid>
    </item>
  </channel>
</rss>
