<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>lzm420241 (Charles)</title>
    <link>https://ruby-china.org/lzm420241</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>如何在 Rails 中配置 Redis 集群?</title>
      <description>&lt;p&gt;我使用 redis gem 包，从 redis 文档中看到提供 sentinel 的支持，其中其配置如下 (link:&lt;a href="https://github.com/redis/redis-rb" rel="nofollow" target="_blank"&gt;https://github.com/redis/redis-rb&lt;/a&gt;)&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;SENTINELS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:port&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;26380&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
             &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:port&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;26381&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="n"&gt;redis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Redis&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;:url&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"redis://mymaster"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:sentinels&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;SENTINELS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:role&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:master&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是根据上述配置，返回的 redis 是 nil，不知道哪里有问题，还望各位大牛指教？&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Mon, 20 Jun 2016 18:45:00 +0800</pubDate>
      <link>https://ruby-china.org/topics/30327</link>
      <guid>https://ruby-china.org/topics/30327</guid>
    </item>
    <item>
      <title>关于样式覆盖问题有没有什么好的解决办法?</title>
      <description>&lt;p&gt;比如说：页面一，body 的样式设置为：&lt;/p&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#b47146&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#f0f0f0&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;/p&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ffb94a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&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;rails 将两个样式全部放入 application 中按照这种顺序，那么页面一的 background-color 样式就会被覆盖掉，有没有好的办法能确保页面一样式使用样式一，页面二样式使用页面二的样式？&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Fri, 03 Jun 2016 15:58:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/30206</link>
      <guid>https://ruby-china.org/topics/30206</guid>
    </item>
    <item>
      <title>URL 解码问题</title>
      <description>&lt;p&gt;我的 url:&lt;a href="http://avators.qiniu.jijiakafei.com/18301736396?e=1461143795u0026token=2VQYwL7KbVJwSfBnILVDSpaGbE7F4qB_7zV6lltd:pmflaXENvJIFtwtpFwwE=" rel="nofollow" target="_blank"&gt;http://avators.qiniu.jijiakafei.com/18301736396?e=1461143795u0026token=2VQYwL7KbVJwSfBnILVDSpaGbE7F4qB_7zV6lltd:pmflaXENvJIFtwtpFwwE=&lt;/a&gt;\
如何中这个 url 中\u0026 解码？&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Wed, 20 Apr 2016 17:02:13 +0800</pubDate>
      <link>https://ruby-china.org/topics/29793</link>
      <guid>https://ruby-china.org/topics/29793</guid>
    </item>
    <item>
      <title>Grape 中如何使用 respond_to</title>
      <description>&lt;p&gt;我用 grape 写的 api 采用 respond_to 的方式&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&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;js&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
              &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;:json&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;results: &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="ss"&gt;title: &lt;/span&gt;&lt;span class="vi"&gt;@user_coupon.title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;value: &lt;/span&gt;&lt;span class="vi"&gt;@coupon_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;end_date: &lt;/span&gt;&lt;span class="vi"&gt;@end_date&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="ss"&gt;statusCode: &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;statusMsg: &lt;/span&gt;&lt;span class="s2"&gt;"恭喜你成功获取优惠券"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;success: &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;:callback&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;:callback&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;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后调用这个 api，服务器返回 500，看了 log 后发现&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;NoMethodError &lt;span class="o"&gt;(&lt;/span&gt;undefined method &lt;span class="sb"&gt;`&lt;/span&gt;respond_to&lt;span class="s1"&gt;' for #&amp;lt;#&amp;lt;Class:0x0000000393f4b0&amp;gt;:0x000000057c3878&amp;gt;):
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;grape 集成在 rails，为什么不可以没有定义 respond_to 这个方法呢？&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Fri, 08 Apr 2016 09:44:03 +0800</pubDate>
      <link>https://ruby-china.org/topics/29626</link>
      <guid>https://ruby-china.org/topics/29626</guid>
    </item>
    <item>
      <title>作为一名初学者,我想问问如何高效使用 convention over configuration 这个原则?</title>
      <description>&lt;p&gt;先说明一下我自己理解什么算是高效？能够理解某个约定的情况下，通过最优的方式使用这个约定&lt;/p&gt;

&lt;p&gt;由于 convention 的存在，rails 隐藏了很多服务端技术的细节 ,我认为这个应该是国内很多人没有使用 rails 开发的一个原因 (当然是个人的猜测),而作为初学者，我最大的困惑是很多功能实现了但是我并不知道里面具体如何实现？这个问题我想是大多数初学者都会遇到的问题。&lt;/p&gt;

&lt;p&gt;我的思考:
第一步：如何深入理解 rails 里面一些 convention 里面的原理，我觉得作为初学者首先要解决这个问题。
第二步：如何利用每一个 convention 的原理写出自己的测试代码，最好能直接调试代码 (目前我还不知道如何调试 ruby 代码，只知道能写测试代码)
第三步：通过上述两部的基础再来解决如何高效使用 convention&lt;/p&gt;

&lt;p&gt;目前，我一直在第一步中徘徊，或许我的思路有些问题，但请各位大牛能指点一二，另外附上原因？谢谢！&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Tue, 29 Mar 2016 16:59:44 +0800</pubDate>
      <link>https://ruby-china.org/topics/29495</link>
      <guid>https://ruby-china.org/topics/29495</guid>
    </item>
    <item>
      <title>在一台 Linux 服务器上配置两个 unicorn worker，为什么在配置第二个服务的时候提示 production is already worker</title>
      <description>&lt;p&gt;我在 linux 上新配置一个 unicorn 服务，然后所有配置文件配置好，启动 unicorn 服务，提示：Unicorn app - production is already running，如何在一台服务器启动多个 unicorn 服务啊？
配置文件都是没问题的，因为可以正常运行，但是两个项目共用同一个端口号 80,&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Fri, 11 Mar 2016 14:55:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/29264</link>
      <guid>https://ruby-china.org/topics/29264</guid>
    </item>
    <item>
      <title>如何利用 Rails 实现一个类似 curl 功能的 API</title>
      <description>&lt;p&gt;我在实现一个微信授权登录的功能，网上找到很多代码都是没有注释的，没怎么看懂，但是微信授权中的整个思路还是理解，我用 php 能实现出来，其中 php 里面含有 curl 的 api，但是在 rails 里面一直没找到这个 api，只能自己模拟 curl 这个功能，但是不知道如何实现这个 API？&lt;/p&gt;</description>
      <author>lzm420241</author>
      <pubDate>Thu, 10 Mar 2016 10:35:18 +0800</pubDate>
      <link>https://ruby-china.org/topics/29253</link>
      <guid>https://ruby-china.org/topics/29253</guid>
    </item>
  </channel>
</rss>
