<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>dingfengju (dingfj)</title>
    <link>https://ruby-china.org/dingfengju</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Rails5 空数据判断后报错死循环?</title>
      <description>&lt;h2 id="代码如下，rails版本5.2.0，ruby版本2.5.1，mysql 5.6.4"&gt;代码如下，rails 版本 5.2.0，ruby 版本 2.5.1，mysql 5.6.4&lt;/h2&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;datas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DDataHourlyYyyy&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="ss"&gt;:data_time&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@last_data_time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:station_id&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@station_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;datas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort!&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aqi&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aqi&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;datas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;present?&lt;/span&gt; &lt;span class="c1"&gt;# 按aqi降序排序&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;报错如下图：
&lt;img src="https://l.ruby-china.com/photo/2018/98c29c7a-727b-4451-ab66-d0174f2c3184.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;劳烦大神解惑，不慎感激！&lt;/p&gt;
&lt;/blockquote&gt;</description>
      <author>dingfengju</author>
      <pubDate>Thu, 30 Aug 2018 10:39:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/37412</link>
      <guid>https://ruby-china.org/topics/37412</guid>
    </item>
    <item>
      <title>Ruby socket 协议问题</title>
      <description>&lt;p&gt;现在一个需求是要通过 socket 协议传输数据，对方是用的 java 搭建的 socket 服务。&lt;/p&gt;

&lt;p&gt;我用的 ruby 写了一个客户端去发送数据。&lt;/p&gt;

&lt;p&gt;他们发了我一个本地测试软件来测试可以正常发送，往对方公司电脑上的这个软件里面也能正常发送，就是往他们服务器上发送没任何反应（其他用 java 写的客户端都能成功）。请各位做过 socket 调试的大牛帮忙提供些问题可能出现的地方。🙏谢谢，坐等…
以下是测试软件的截屏&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2017/5b1ecde4-15b9-4df3-9372-4418e950fc04.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>dingfengju</author>
      <pubDate>Fri, 18 Aug 2017 10:55:16 +0800</pubDate>
      <link>https://ruby-china.org/topics/33873</link>
      <guid>https://ruby-china.org/topics/33873</guid>
    </item>
    <item>
      <title>Rails 怎么实现不同的域名访问的页面不同</title>
      <description>&lt;p&gt;今天遇到一个问题，根据不同的域名，比如：ht.zzz.com 访问显示后台登录界面，qt.zzz.com 访问前台页面&lt;/p&gt;

&lt;p&gt;我实现的办法是 在 ApplicationController 写了一个 before_action，实现了不同域名的访问，但是就是不能访问其他页面，只用 redirect to 就会报重定向死循环问题，求指导
代码如下：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;url_str&lt;/span&gt;
    &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="sr"&gt;/^ht\./&lt;/span&gt;
      &lt;span class="n"&gt;redirect_to&lt;/span&gt; &lt;span class="ss"&gt;:controller&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'/admin_users/sessions'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;action: &lt;/span&gt;&lt;span class="s2"&gt;"new"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:is_redirect_to&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&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;:is_redirect_to&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;blank?&lt;/span&gt;
    &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="sr"&gt;/^qt\./&lt;/span&gt;
      &lt;span class="n"&gt;redirect_to&lt;/span&gt; &lt;span class="ss"&gt;:controller&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'/root'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;action: &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:is_redirect_to&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&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;:is_redirect_to&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;blank?&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>dingfengju</author>
      <pubDate>Mon, 05 Dec 2016 18:52:39 +0800</pubDate>
      <link>https://ruby-china.org/topics/31805</link>
      <guid>https://ruby-china.org/topics/31805</guid>
    </item>
  </channel>
</rss>
