<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>fengzhilian818 (阿错啦噶)</title>
    <link>https://ruby-china.org/fengzhilian818</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>如何配置 Redis 读写分离？</title>
      <description>&lt;p&gt;有 A,B,C 三台服务器，上面分别有 redis1(主服务器),redis2(从服务器),redis3(从服务器)，B,C 两台服务器的缓存 write 到 A 服务器的 redis1，再由 A 服务器 redis1 同步到 redis2 和 redis3，请教大家有没有什么方式在 rails 里面配置成读写分离&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Wed, 26 Apr 2017 18:17:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/32876</link>
      <guid>https://ruby-china.org/topics/32876</guid>
    </item>
    <item>
      <title>cache_key 如何去掉域名那一段？</title>
      <description>&lt;p&gt;现在实现将接口缓存放在 redis，key 为 space:views/localhost:3000/controller/method/x.json，现在需求是将 localhost:3000 去掉，求各位前辈给个解决方案呗&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 10 Apr 2017 17:59:30 +0800</pubDate>
      <link>https://ruby-china.org/topics/32743</link>
      <guid>https://ruby-china.org/topics/32743</guid>
    </item>
    <item>
      <title>crontab 执行 rake 遇到 cannot load such file -- bundler/setup</title>
      <description>&lt;p&gt;在 crontab 添加 0 */1 * * * /xxx/rebuild_index.sh &amp;gt; /www/reindex.log 2&amp;gt;&amp;amp;1 任务并打印日志。&lt;/p&gt;

&lt;p&gt;/xxx/rebuild_index.sh的内容为：
#! /bin/bash&lt;br&gt;
export LC_ALL=en_US.UTF-8
export PATH='/usr/local/bin':$PATH&lt;br&gt;
cd /www/app
RAILS_ENV=production /usr/local/bin/rake sunspot:reindex&lt;/p&gt;

&lt;p&gt;日志报错为：
rake aborted!
LoadError: cannot load such file -- bundler/setup
/www/app/config/boot.rb:3:in &lt;code&gt;&amp;lt;top (required)&amp;gt;'
/www/app/config/application.rb:1:in&lt;/code&gt;'
/www/app/Rakefile:4:in `'
(See full trace by running task with --trace)&lt;/p&gt;

&lt;p&gt;求大神指点一二&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Wed, 22 Feb 2017 18:14:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/32362</link>
      <guid>https://ruby-china.org/topics/32362</guid>
    </item>
    <item>
      <title>关于 caches_caches_page 问题</title>
      <description>&lt;p&gt;接口为 p6/video/hot_videos/2/1.json?version=x'x'x_2.3.0
生成的缓存文件为在 public 目录：D:\xxxxx\public\p6\video\hot_videos\3\1.json
现在要求对不同的 version 生成 D:\xxxxx\public\p6\video\hot_videos\3\1.json?version=x'x'x_2.3.0 的文件
不知各位大神知道怎么做么？
用的 gem 是 actionpack-page_caching&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Tue, 24 May 2016 17:48:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/30108</link>
      <guid>https://ruby-china.org/topics/30108</guid>
    </item>
    <item>
      <title>Rails 批量插入数据的方法和效率</title>
      <description>&lt;p&gt;如题，Rails 有没有批量插入数据的方法，我看了下 create 方法生成的 sql 是多个 insert，有没有一个 insert，多个 values 的方法呢，或者其他的批量插入数据的方法；我们应用现在有个关联 facebook、微博等的功能，在关联之后会建立微博好友关系，关联的时候插入的数据比较多。&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 11 Aug 2014 11:01:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/20949</link>
      <guid>https://ruby-china.org/topics/20949</guid>
    </item>
    <item>
      <title>随机取指定范围内的数据</title>
      <description>&lt;p&gt;把地图分成 6 个区域，每个区域有 0 到 N 个数据。随机从六个区域取出 5 个数据（数据总数不足 5 个时，取出数据可小于 5 个，每个区域最多取出 2 个数据）。请教各位大神在算法上能有什么指点吗？&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Wed, 06 Aug 2014 17:56:46 +0800</pubDate>
      <link>https://ruby-china.org/topics/20875</link>
      <guid>https://ruby-china.org/topics/20875</guid>
    </item>
    <item>
      <title>怎么才能让 Rails 的 session 在 post 后不会被清空作用域</title>
      <description>&lt;p&gt;ROR 的 session 作用域怎么才能在页面 Post 提交后不会被清空，能够在提交之后还能继续使用，现在开始做一个网站，一直会这样，有木有好的教程之类的，还是说我做错了什么东西，&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Tue, 29 Jul 2014 11:58:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/20729</link>
      <guid>https://ruby-china.org/topics/20729</guid>
    </item>
    <item>
      <title>Rails 需要对参数进行一些验证吗？</title>
      <description>&lt;p&gt;Rails 的 Active Record 数据验证，是对存入数据库之前进行了数据验证，那 Controller 有没有必要对参数进行一些验证呢？（APP &amp;amp; Web）如果对参数进行了验证，验证失败就不用去调用 model？响应是不是快些，还有考虑到用户禁用 Javascript 的什么的。&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Fri, 18 Jul 2014 13:22:10 +0800</pubDate>
      <link>https://ruby-china.org/topics/20568</link>
      <guid>https://ruby-china.org/topics/20568</guid>
    </item>
    <item>
      <title>RoR 后台改为 Swift 来写是否可以</title>
      <description>&lt;p&gt;现在我们用 Ruby 做后台做了 ipad 应用，叫 iCaper，最近苹果出了 swift 语言，想去学习学习，我没有 oc 的基础，但是我现在想弄清楚，不知道 Swift 可不可以代替 Ruby 来实现后台呢？我听我们 oc 的开发者说是可以的，不知道是否真的可以。&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Thu, 03 Jul 2014 12:20:47 +0800</pubDate>
      <link>https://ruby-china.org/topics/20293</link>
      <guid>https://ruby-china.org/topics/20293</guid>
    </item>
    <item>
      <title>数据处理效率</title>
      <description>&lt;p&gt;最近我们开发的应用在更新版本 2.0。将几种类型数据在数据表一个字段存储和查询有点小分歧。我们分歧在于是将该字段的数据查询出来循环并封装成 json 类型再传给前台，还是直接查询出来直接传给前台由前台自己循环取出数据效率更高。希望能在大家在数据处理效率上给与些意见。。。（注：我们后台是用 ruby 而前台是 IOS，应用的名字叫 iCaper）&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 16 Jun 2014 19:10:12 +0800</pubDate>
      <link>https://ruby-china.org/topics/19973</link>
      <guid>https://ruby-china.org/topics/19973</guid>
    </item>
    <item>
      <title>关于 rails 的跑脚本问题</title>
      <description>&lt;p&gt;我们正开发的 iCaper 项目是一个苹果的 app 应用，后台现在在处理跑脚本时使用的是 rufus-scheduler，但是在服务器上跑的时候，如果在连续 5 分钟到 10 分钟的时间内项目没有被访问，脚本就停掉了，就不再跑，然后当有访问的时候，脚本才会重新跑起来，请问要怎么让脚本在项目一直没有被访问时也不会停掉？&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Fri, 06 Jun 2014 18:40:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/19792</link>
      <guid>https://ruby-china.org/topics/19792</guid>
    </item>
    <item>
      <title>关于 rails 数据库连接、事务、预编译和批处理的困惑</title>
      <description>&lt;p&gt;接触 rails 没多久，公司现在在做一个 APP 项目 iCaper，想知道 Rails 的很多 find_by_id, find_all_by_name ...等等这些方法，在一个 action 里面多次调用的时候，数据库连接是用的同一个吗，是在同一个事务下吗？（Tips：ruby 或 rails 怎样让同一个线程中的不同模块间共享同一个数据，比如数据库连接？）&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;index&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="vi"&gt;@other_productions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all_by_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="vi"&gt;@my_productions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all_by_user_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&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;还有预编译之后进行批处理数据库操作，有木有这样的方法呢，求详解！&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 26 May 2014 18:50:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/19549</link>
      <guid>https://ruby-china.org/topics/19549</guid>
    </item>
    <item>
      <title>用户账户安全问题</title>
      <description>&lt;p&gt;&lt;img src="//l.ruby-china.com/photo/2014/21ceda3b39cfd2c074c90521d1f68d8d.png" title="" alt=""&gt;
我们团队用 iOS 做前台，ruby 做后台开发了一款叫 icaper 的苹果应用，为了保护账户的安全，大家有没有简洁实用的密码措施保障用户账号安全呢？
现在我们采用的是四位数字密码让用户登录，常规三个密保问题可以为用户找回账号。之前也有想过用九宫格图形密码验证用户登录，我们想让用户既方便又安全。&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Wed, 21 May 2014 15:38:48 +0800</pubDate>
      <link>https://ruby-china.org/topics/19448</link>
      <guid>https://ruby-china.org/topics/19448</guid>
    </item>
    <item>
      <title>Google 地图上实现自定义抛物线</title>
      <description>&lt;p&gt;现在正在做的项目第二版的设计出来了，需要用到 Google 地图来代替原来的地球背景图，还要做一个用户和周围用户的一个抛物线的连接，但是找遍了 google 的连接函数，都没有找到自定义的抛物线方法，而用 Google 的连接方法，要么是直的，要么就按照地球的幅度进行弯曲，不能自己设置弯曲弧度，请问有木有其它方法来实现在 Google 地图上自定义连接线实现抛物线的连接。附上项目的官网访问地址：&lt;a href="http://icaper.net" rel="nofollow" target="_blank"&gt;http://icaper.net&lt;/a&gt;&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 12 May 2014 09:20:35 +0800</pubDate>
      <link>https://ruby-china.org/topics/19185</link>
      <guid>https://ruby-china.org/topics/19185</guid>
    </item>
    <item>
      <title>求科普数据库外键及常用字段的建表方法，遇到一个问题，详见帖子内容</title>
      <description>&lt;p&gt;正在做的一个项目 iCaper，遇到一个纠结的问题，我有两张表 user 表（用户表）和 dance 表（用户的舞蹈表），dance 表的用户 ID 是外键（user 表），但是 dance 表很频繁的在用到用户名，那么这种情况是可以直接把用户名也放在 dance 表的字段中吗？还是每次用的时候到 user 表去取呢？
1、用户名放在 dance 表中的话，感觉不是很合理，改用户名还得一起同时改，而且浪费资源；
2、用户名不放在 dance 表中的话，在查询 dance 的时候又常用到用户名，这样查询两个表效率会不会成为一个问题呢。
好纠结，有大神给普及下数据库知识不？
附上 iCaper 网站链接：icaper.net（网页精简版）第二版正在开发，改了好多，感觉好玩了很多，IOS 和 UI 组的同事很给力的额！！！&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 28 Apr 2014 19:11:42 +0800</pubDate>
      <link>https://ruby-china.org/topics/18899</link>
      <guid>https://ruby-china.org/topics/18899</guid>
    </item>
    <item>
      <title>关于用贝赛尔曲线在页面画两个点之间弧线连线</title>
      <description>&lt;p&gt;最近在用 JS 在页面用地图图片做背景图片，在地图上用两点表示两个的坐标位置。点击一个坐标点用贝塞尔曲线动态表示连接两个点。再次点击该点弧线动态收缩。
目前我用贝塞尔公式：
x=(1-t)² × x0 +2t(1-t) × x1+t² × x2;
y=(1-t)² × y0+2t(1-t) × y1+t² × y2;(t=0→1)
 
   画线效果是曲线不够圆滑，弧线收放速度不够均匀，不知道哪位高人有更好的方式动态画弧线？类似地球定位功能的网站如：icaper.net。iPad 版的地球在一个 APP 里面，APP 地址：&lt;a href="http://t.cn/8FFxXfK" rel="nofollow" target="_blank"&gt;http://t.cn/8FFxXfK&lt;/a&gt;&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 21 Apr 2014 16:32:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/18750</link>
      <guid>https://ruby-china.org/topics/18750</guid>
    </item>
    <item>
      <title>Ruby 或 JS 图片合成视频</title>
      <description>&lt;p&gt;最近在用 Ruby 或者 JS 把一系列图片合成视频，但是又必须要流畅，找了其它一些类似的效果，发现一款叫 iCaper 的 ipad 应用里面做得很不错，里面就是把用户操作的一些动画给合成视频，而且它的官网&lt;a href="http://icaper.net" rel="nofollow" target="_blank"&gt;http://icaper.net&lt;/a&gt; 上也用 JS 实现了连续播放图片的功能，这个动画以及 ipad 里合成的视频看起来都很流畅，用 Ruby 怎么做到这种图片合成视频的功能呢？&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 14 Apr 2014 11:13:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/18587</link>
      <guid>https://ruby-china.org/topics/18587</guid>
    </item>
    <item>
      <title>关于 Google Map 定位到街道的问题</title>
      <description>&lt;p&gt;最近在用 JS 调用 Google map 的 API，做一个地球自动定位，并连线附近的好友这样一个功能，关于自动定位到街道在 iPad 和网页上都是怎么实现的呢？不一定要用 JS，用 Ruby 也行。我这儿有个网站，是之前同组的 JS 同事做的，在他的基础上改，地址：icaper.net。iPad 版的地球在一个 APP 里面，APP 地址：&lt;a href="http://t.cn/8FFxXfK" rel="nofollow" target="_blank"&gt;http://t.cn/8FFxXfK&lt;/a&gt;。高人留步！！！&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Tue, 08 Apr 2014 10:47:49 +0800</pubDate>
      <link>https://ruby-china.org/topics/18461</link>
      <guid>https://ruby-china.org/topics/18461</guid>
    </item>
    <item>
      <title>ruby 实现地图效果</title>
      <description>&lt;p&gt;最近用百度的 API 尝试着做一个地图路线的 demo，现在想借用 smule 应用和网上一个新应用叫 Icaper 的对比，这两个应用里都有地图展示，Icaper 的做的似乎更细致，不知道哪位大神知道可以用 ruby 实现这样的功能不？&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Mon, 31 Mar 2014 11:14:33 +0800</pubDate>
      <link>https://ruby-china.org/topics/18276</link>
      <guid>https://ruby-china.org/topics/18276</guid>
    </item>
    <item>
      <title>服务器 Scheduler 脚本被挂起</title>
      <description>&lt;p&gt;将下面的脚本放在服务器的项目中，如果项目一段时间没有被访问，下面的脚本就会停止执行，只有访问服务器脚本才会又定时执行。请教各位这个问题怎么解决才能让脚本自己也能定时执行而不会被挂起
 require 'rubygems'
 require 'rufus/scheduler'&lt;/p&gt;

&lt;p&gt;scheduler1 = Rufus::Scheduler.start_new
scheduler1.every '5s' do
    puts 'xxxxxxxxxxxxxxx'
end&lt;/p&gt;</description>
      <author>fengzhilian818</author>
      <pubDate>Thu, 19 Dec 2013 14:27:08 +0800</pubDate>
      <link>https://ruby-china.org/topics/16309</link>
      <guid>https://ruby-china.org/topics/16309</guid>
    </item>
  </channel>
</rss>
