<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>ThanksSirAlec</title>
    <link>https://ruby-china.org/ThanksSirAlec</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>部署阿里云 k8s 集群报错</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;ruby&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;2.6&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;alpine&lt;/span&gt;

&lt;span class="no"&gt;WORKDIR&lt;/span&gt; &lt;span class="sr"&gt;/deploy

COPY Gemfile Gemfile.lock ./&lt;/span&gt;

&lt;span class="no"&gt;ENV&lt;/span&gt; &lt;span class="no"&gt;LANG&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;
&lt;span class="no"&gt;ENV&lt;/span&gt; &lt;span class="no"&gt;LC_ALL&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;

&lt;span class="no"&gt;RUN&lt;/span&gt; &lt;span class="n"&gt;apk&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;build_deps&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="n"&gt;ruby&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt; &lt;span class="n"&gt;libc&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="n"&gt;libxml2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;apk&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;postgresql&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt; &lt;span class="n"&gt;libxslt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;bundler&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;bundle&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;set&lt;/span&gt; &lt;span class="n"&gt;without&lt;/span&gt; &lt;span class="s1"&gt;'development:test:doc'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;bundle&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;rm&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;rf&lt;/span&gt; &lt;span class="sr"&gt;/usr/&lt;/span&gt;&lt;span class="n"&gt;lib&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ruby&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;gems&lt;/span&gt;&lt;span class="o"&gt;/*&lt;/span&gt;&lt;span class="sr"&gt;/cache/&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;apk&lt;/span&gt; &lt;span class="n"&gt;del&lt;/span&gt; &lt;span class="n"&gt;build_deps&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;\&lt;/span&gt;
    &lt;span class="n"&gt;rm&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;rf&lt;/span&gt; &lt;span class="sr"&gt;/var/&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;apk&lt;/span&gt;&lt;span class="o"&gt;/*&lt;/span&gt; &lt;span class="sr"&gt;/tmp

COPY ./&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;/&lt;/span&gt;

&lt;span class="no"&gt;ENTRYPOINT&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/deploy/deploy/entry-puma.sh"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;写了一个 dockerfile，镜像构建成功，本地跑也没问题，但是部署了阿里云的 k8s 集群就报 &lt;code&gt;standard_init_linux.go:207: exec user process caused "no such file or directory"&lt;/code&gt; 有没有知道这是什么情况。。。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Fri, 29 May 2020 18:48:23 +0800</pubDate>
      <link>https://ruby-china.org/topics/39919</link>
      <guid>https://ruby-china.org/topics/39919</guid>
    </item>
    <item>
      <title>Rails Mailer 传 CSV 文件的时候乱码</title>
      <description>&lt;p&gt;代码如下&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;file_names&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;file_name&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;attachments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;file_name&lt;/span&gt;&lt;span class="p"&gt;]&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;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file_name&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;byebug&lt;/span&gt;

&lt;span class="n"&gt;mail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="ss"&gt;to: &lt;/span&gt;&lt;span class="s1"&gt;'XXXX'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="ss"&gt;subject: &lt;/span&gt;&lt;span class="s2"&gt;"XXXX"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后收到的邮件是这样的。。。&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2020/df24024f-cbb1-4fdd-aec1-01521a7209f9.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;尝试过 &lt;code&gt;{mime_type: 'text/csv', content: File.read(Rails.root.join(file_name))}&lt;/code&gt; 得到的结果是一样的，有谁知道这个是怎么回事吗&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 27 Apr 2020 23:34:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/39806</link>
      <guid>https://ruby-china.org/topics/39806</guid>
    </item>
    <item>
      <title>为什么需要同时使用 nginx 和 puma</title>
      <description>&lt;p&gt;如题，为什么生产环境需要两个服务器，他们都分别做了什么。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 07 May 2019 18:04:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/38490</link>
      <guid>https://ruby-china.org/topics/38490</guid>
    </item>
    <item>
      <title>Ruby 中的 Time 有没有什么方法舍弃掉分钟和秒</title>
      <description>&lt;p&gt;目前的做法是&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;time = Time.now
new_time = Time.new(time.year, time.month, time.day, time.hour)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;有没有更好的方法&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 16 Apr 2019 18:07:23 +0800</pubDate>
      <link>https://ruby-china.org/topics/38412</link>
      <guid>https://ruby-china.org/topics/38412</guid>
    </item>
    <item>
      <title>Rails 起服务的时候报错但是信息过长被截断</title>
      <description>&lt;p&gt;追溯的报错路经大概有 4000 多行，在终端被截断了，有没有什么办法能显示全部的路径，或者隐藏之前的路径。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 08 Apr 2019 19:57:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/38364</link>
      <guid>https://ruby-china.org/topics/38364</guid>
    </item>
    <item>
      <title>Ruby 正则的问题</title>
      <description>&lt;p&gt;我有一个字符串&lt;code&gt;str = 'ST (Wechat Mini program)'&lt;/code&gt; 
如果我用&lt;code&gt;/ST (Wechat Mini program)/ =~  srr&lt;/code&gt; 会返回 nil，求解这是为什么&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 03 Jul 2018 14:04:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/37081</link>
      <guid>https://ruby-china.org/topics/37081</guid>
    </item>
    <item>
      <title>定义好方法之后报了 NoMethodError</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;Gitlab&lt;/span&gt;
  &lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;Client&lt;/span&gt;
    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;
        &lt;span class="s1"&gt;'it is a method'&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;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;我在 rails c 里面用 &lt;code&gt;Gitlab::Client.foo&lt;/code&gt; 出现了 &lt;code&gt;NoMethodError: undefined method 'foo' for Gitlab::Client:Class&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;这是为什么&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 15 May 2018 11:23:43 +0800</pubDate>
      <link>https://ruby-china.org/topics/36777</link>
      <guid>https://ruby-china.org/topics/36777</guid>
    </item>
    <item>
      <title>有人用过 AWS 的官方 SDK 吗，有点不理解。</title>
      <description>&lt;p&gt;我用&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Aws&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;S3&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Client&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;region: &lt;/span&gt;&lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="ss"&gt;access_key_id: &lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'access_key_id'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="ss"&gt;secret_access_key: &lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'secret_access_key'&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;这样的方式，但是报了 &lt;code&gt;Seahorse::Client::NetworkingError: execution expired&lt;/code&gt; 的错误，谁知道是什么意思&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Wed, 18 Apr 2018 18:24:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/35482</link>
      <guid>https://ruby-china.org/topics/35482</guid>
    </item>
    <item>
      <title>关于 alias_method 的作用范围问题</title>
      <description>&lt;p&gt;自己在 ruby 中尝试用 &lt;code&gt;alias_method&lt;/code&gt; 发现这个语句一定要写在定义方法之后使用才有效。但是在 rails 项目里看到 &lt;code&gt;alias_method&lt;/code&gt; 都是写在最前面的，请教一下这个里面的区别。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 02 Apr 2018 11:34:10 +0800</pubDate>
      <link>https://ruby-china.org/topics/35380</link>
      <guid>https://ruby-china.org/topics/35380</guid>
    </item>
    <item>
      <title>有没有办法跳过 add_index 的 unique 验证</title>
      <description>&lt;p&gt;给 QA 做假数据的时候发现之前表在创建的时候加了&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_index ..... unique: true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;用 &lt;code&gt;save(validate: false)&lt;/code&gt; 的方法没法跳过验证，请问这个验证有办法跳过吗？&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 19 Mar 2018 16:43:16 +0800</pubDate>
      <link>https://ruby-china.org/topics/35265</link>
      <guid>https://ruby-china.org/topics/35265</guid>
    </item>
    <item>
      <title>关于在 index 中处理 query 的问题</title>
      <description>&lt;p&gt;我想统计一个变量的某一个值的 count. 但是这个值又要符合一些条件，如果不把 query 放在 view 中，只从&lt;code&gt;def index&lt;/code&gt;中处理应该怎么做。
比如：本来应该是&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exp1&lt;/span&gt; &lt;span class="vi"&gt;@example1&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;example1&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt; &lt;span class="n"&gt;example1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;example2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'some condition'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;现在如果我想在把这个 query 放在 index 这个 action 中执行，然后用一个实例变量在 view 中返回，有没有办法实现。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 30 Jan 2018 10:57:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/34967</link>
      <guid>https://ruby-china.org/topics/34967</guid>
    </item>
    <item>
      <title>怎么样才算熟悉一个数据库和 linux</title>
      <description>&lt;p&gt;看到招聘的要求里大多都谢了，熟悉 Linux，关系和非关系型数据库，怎么样才算熟悉&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 29 Jan 2018 11:10:33 +0800</pubDate>
      <link>https://ruby-china.org/topics/34958</link>
      <guid>https://ruby-china.org/topics/34958</guid>
    </item>
    <item>
      <title>action mailer 可以在发送之前让发送的人进行编辑吗</title>
      <description>&lt;p&gt;如题&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 29 Jan 2018 09:38:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/34957</link>
      <guid>https://ruby-china.org/topics/34957</guid>
    </item>
    <item>
      <title>RSpec update 遇到一个问题</title>
      <description>&lt;p&gt;写了一个很简单的测试&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;let&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:coupon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;FactoryGirl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:coupon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s1"&gt;'can update a coupon'&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;coupon&lt;/span&gt;
      &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;put&lt;/span&gt; &lt;span class="ss"&gt;:update&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;id: &lt;/span&gt;&lt;span class="n"&gt;coupon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;discount: &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;
      &lt;span class="p"&gt;}.&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;change&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;coupon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:discount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;我在 controller 里面添加了 debugger 确确实实的看到了 discount 值从 20 变到 40，但是为什么回到测试代码的时候值就🈶回到 20 了，怎么测都过不了&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Thu, 25 Jan 2018 15:23:43 +0800</pubDate>
      <link>https://ruby-china.org/topics/34947</link>
      <guid>https://ruby-china.org/topics/34947</guid>
    </item>
    <item>
      <title>Active Record 的问题</title>
      <description>&lt;p&gt;我想在要写一个接口，返回用户的名字和邮箱
我的&lt;code&gt;index.json.jbuilder&lt;/code&gt;是这样的&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;users&lt;/span&gt; &lt;span class="vi"&gt;@user&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;user&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;
  &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;email&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;email&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是有时候按搜索条件，这个&lt;a href="/user" class="user-mention" title="@user"&gt;&lt;i&gt;@&lt;/i&gt;user&lt;/a&gt;只有一个，这个时候就会报 undefined method &lt;code&gt;map&lt;/code&gt; 的错误，请问这个问题怎么解决&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Fri, 19 Jan 2018 13:55:30 +0800</pubDate>
      <link>https://ruby-china.org/topics/34919</link>
      <guid>https://ruby-china.org/topics/34919</guid>
    </item>
    <item>
      <title>RSpec 的 controller spec</title>
      <description>&lt;p&gt;我的路由资源是这么定义的&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;resources&lt;/span&gt; &lt;span class="ss"&gt;:example1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;only: &lt;/span&gt;&lt;span class="sx"&gt;%i(index)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;shallow: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
          &lt;span class="n"&gt;resources&lt;/span&gt; &lt;span class="ss"&gt;:example2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;module: &lt;/span&gt;&lt;span class="s1"&gt;'example1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;only: &lt;/span&gt;&lt;span class="sx"&gt;%i(create update destroy show index)&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;example2 放在了 example1 的文件夹下面。
然后运行测试的时候得到了&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;No route matches &lt;span class="o"&gt;{&lt;/span&gt;:action&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;, :controller&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"example1/example2"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;和&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;No route matches &lt;span class="o"&gt;{&lt;/span&gt;:action&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"show"&lt;/span&gt;, :controller&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"example1/example2"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;的错误&lt;/p&gt;

&lt;p&gt;一下的 spec 的代码&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;RSpec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;describe&lt;/span&gt; &lt;span class="no"&gt;Example1&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Example2Controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: :controller&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;describe&lt;/span&gt; &lt;span class="s2"&gt;"GET index"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;"has a 200 status code"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="ss"&gt;:index&lt;/span&gt;
      &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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="n"&gt;describe&lt;/span&gt; &lt;span class="s2"&gt;"GET show"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;"has a 200 status code"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="ss"&gt;:show&lt;/span&gt;
      &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&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;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Thu, 18 Jan 2018 12:15:17 +0800</pubDate>
      <link>https://ruby-china.org/topics/34907</link>
      <guid>https://ruby-china.org/topics/34907</guid>
    </item>
    <item>
      <title>请问哪里有 Rspec 基本语法的文档吗</title>
      <description>&lt;p&gt;就是那就 should，let 什么的怎么用的，这类的文档&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Mon, 15 Jan 2018 10:03:23 +0800</pubDate>
      <link>https://ruby-china.org/topics/34881</link>
      <guid>https://ruby-china.org/topics/34881</guid>
    </item>
    <item>
      <title>Ruby eval 是什么意思</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&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;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;如题，eval 这个找了半天没找到官方说明，不知道是干什么用的，有大佬能解释一下或者给个链接吗&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Fri, 05 Jan 2018 14:22:34 +0800</pubDate>
      <link>https://ruby-china.org/topics/34828</link>
      <guid>https://ruby-china.org/topics/34828</guid>
    </item>
    <item>
      <title>ruby schema.rb 文件是干什么用的</title>
      <description>&lt;p&gt;背景：在项目里项目里看到了一个 example model，但是在 app/db/migrate 文件夹里面没有发现 ********* create_examples.rb 的文件。
只在 schema 里面发现了 &lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;create_table&lt;/span&gt; &lt;span class="s2"&gt;"example"&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;t&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这样一个块。&lt;/p&gt;

&lt;p&gt;求大佬解释一下&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Wed, 03 Jan 2018 16:36:19 +0800</pubDate>
      <link>https://ruby-china.org/topics/34813</link>
      <guid>https://ruby-china.org/topics/34813</guid>
    </item>
    <item>
      <title>请问各位大佬，在已知一个 url 的情况下有什么办法能确定这个 url 对应的路由辅助方法</title>
      <description>&lt;p&gt;比如知道一个/example1/example2/:id 这样子的 url。怎么知道这个 url 有没有路由辅助方法，如果有的话能不能知道这个辅助方法是什么。&lt;/p&gt;</description>
      <author>ThanksSirAlec</author>
      <pubDate>Tue, 02 Jan 2018 11:34:31 +0800</pubDate>
      <link>https://ruby-china.org/topics/34805</link>
      <guid>https://ruby-china.org/topics/34805</guid>
    </item>
  </channel>
</rss>
