<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>flybee (阳光🌈 小白马)</title>
    <link>https://ruby-china.org/flybee</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>RubyGems 镜像源拉胯</title>
      <description>&lt;p&gt;建议大家还是用阿里云的 rubygem 镜像源吧
ruby china 的镜像源真的太拉胯了。。。。
天天 502。。。。&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2020/11867967-534a-4d9c-b326-b42d33c3f140.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Wed, 30 Dec 2020 14:39:32 +0800</pubDate>
      <link>https://ruby-china.org/topics/40765</link>
      <guid>https://ruby-china.org/topics/40765</guid>
    </item>
    <item>
      <title>如何获取微信聊天消息？</title>
      <description>&lt;p&gt;我加了几个微信群，有没有什么技术方案能实现：把这些群里面的聊天记录实时的转发到我指定的服务器，以便后续分析使用？
是不是实现不了？&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Fri, 30 Aug 2019 17:29:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/39002</link>
      <guid>https://ruby-china.org/topics/39002</guid>
    </item>
    <item>
      <title>rails c 启动控制台，为何不加载 lib 里面的代码？</title>
      <description>&lt;p&gt;rails c 启动控制台，为何不加载 lib 里面的代码？不能在控制台里面调用 lib 里面定义的类方法，必须手动 require 一下代码文件路径才行&lt;/p&gt;

&lt;p&gt;rails 版本 5.2.3&lt;/p&gt;

&lt;p&gt;加载路径配置如下：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;autoload_paths&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&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="s1"&gt;'lib/*'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eager_load_paths&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&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="s1"&gt;'lib/*'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>flybee</author>
      <pubDate>Thu, 25 Jul 2019 18:38:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/38874</link>
      <guid>https://ruby-china.org/topics/38874</guid>
    </item>
    <item>
      <title>Rails 日志配置修改</title>
      <description>&lt;p&gt;我想在 Rails 的请求日志里面，打印出来访者的 session 值，这样能够更加准确的最终一个用户的访问记录，以便于调试问题
请问如何做到？
在网上收到的答案是：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log_tags&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="p"&gt;,&lt;/span&gt;
  &lt;span class="ss"&gt;:remote_ip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;lambda&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nb"&gt;lambda&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cookie_jar&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_session_id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;]&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;</description>
      <author>flybee</author>
      <pubDate>Thu, 11 Jul 2019 10:47:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/38828</link>
      <guid>https://ruby-china.org/topics/38828</guid>
    </item>
    <item>
      <title>rails capistrano-passenger 重启应用失败的问题</title>
      <description>&lt;p&gt;执行几次的部署之后（完成 5 次部署），就会部署失败，报错信息：Bundler::GemfileNotFound，报错语句：passenger-config restart-app /XXX/XXX/XXX --ignore-app-not-running&lt;/p&gt;

&lt;p&gt;背景：
使用 passenger 作为 app server, capistrano 作部署工具
使用了 gem 'capistrano-passenger'完成 restart app 的任务，实际执行命令为：passenger-config restart-app /XXX/XXX/XXX --ignore-app-not-running&lt;/p&gt;

&lt;p&gt;找的答案如下：&lt;a href="https://stackoverflow.com/questions/15393462/what-can-i-do-about-a-bundlergemfilenotfound-error" rel="nofollow" target="_blank"&gt;https://stackoverflow.com/questions/15393462/what-can-i-do-about-a-bundlergemfilenotfound-error&lt;/a&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“In my experience, this will occur when your code is not executing in the directory you think it is (hence the previous answer), or the directory containing the Gemfile has been moved or deleted.
I experienced this when I had been running unicorn on a server running an app that had been deployed with Capistrano. After cleaning up some old "releases" folders, I got this error when I tried to cap deploy a new release.
Because unicorn had been started with bundle exec, it was still using the Gemfile from the directory it was started in; sending the USR2 signal would tell it to reload the application, but it will still use the old Gemfile before loading the newly-deployed app. Of course, I had deleted that Gemfile when I deleted the old releases.
The solution was to restart unicorn with a new bundle exec in the new directory, to load the new Gemfile and then the new app.
So, the answer above is correct. You just need to figure out why the Gemfile you thought you were using is not being used.”
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;有人遇到这种情况吗？如何解决的？&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Sat, 20 Oct 2018 17:50:58 +0800</pubDate>
      <link>https://ruby-china.org/topics/37654</link>
      <guid>https://ruby-china.org/topics/37654</guid>
    </item>
    <item>
      <title>如何禁用 Rails 的 Assets Pipleline?</title>
      <description>&lt;p&gt;rails 5.2.1&lt;/p&gt;

&lt;p&gt;配置了：config.assets.enabled = false&lt;/p&gt;

&lt;p&gt;但是 stylesheet_link_tag 的 helper 方法还是提示找不到静态资源
代码如下：&lt;/p&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;stylesheet_link_tag&lt;/span&gt; &lt;span class="s2"&gt;"site/reset"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;提示错误如下：
ActionView::Template::Error (The asset "site/reset.css" is not present in the asset pipeline.)&lt;/p&gt;

&lt;p&gt;public 目录如下：
&lt;img src="https://l.ruby-china.com/photo/2018/003d7fca-9b2b-47c2-97cc-bba0b7299db1.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Wed, 10 Oct 2018 12:01:39 +0800</pubDate>
      <link>https://ruby-china.org/topics/37607</link>
      <guid>https://ruby-china.org/topics/37607</guid>
    </item>
    <item>
      <title>请教 Rails + Passenger + Capistrano 部署</title>
      <description>&lt;p&gt;在线上开发环境下使用 rvm 安装 ruby，并且创建了该应用使用的 gemset
使用 capistrano/passenger 来进行启动/重启服务器，如何切换 gemset?
感觉没有啥好的方法来切换 gemset 啊&lt;/p&gt;

&lt;p&gt;找到的 work around 的方法如下：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;不使用专用的 gemset，而使用默认的 global gemset；&lt;/li&gt;
&lt;li&gt;不使用 capistrano/passenger 来进行启动/重启服务器，在 deploy:publishing 之后加钩子，自己写启动命令；&lt;/li&gt;
&lt;li&gt;改变 "[[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;amp;&amp;amp; source "$HOME/.rvm/scripts/rvm""的位置，将该语句放置在.bashrc 文件中（nonlogin bash 会加载.bashrc），
但是这样的话又会和 rvm1/capistrano3 有一定的冲突;（该方法感觉不纯洁了）&lt;/li&gt;
&lt;li&gt;定制化启动 passenger, set :passenger_restart_command, "source $HOME/.bash_profile &amp;amp;&amp;amp; cd #{release_path} &amp;amp;&amp;amp; rvm use #{fetch(:rvm1_ruby_version)} &amp;amp;&amp;amp; passenger-config restart-app" （该方法感觉也不纯洁了）&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;请问大家有啥方法没？&lt;/p&gt;

&lt;p&gt;PS：使用 rvm1/capistrano3 可以保证在 bundle install 的时候，gem 的安装是正确的，可以安装到正确的 gemset 中（&lt;a href="https://rvm.io/integration/capistrano" rel="nofollow" target="_blank"&gt;https://rvm.io/integration/capistrano&lt;/a&gt;文档的第一种方法）&lt;/p&gt;

&lt;p&gt;个人感觉，rvm 和 capistrano 是本质上就冲突的，rvm 利用切换环境变量来使用 ruby 和 gemset，而 capistrano 是非登录 shell 的方式部署，本身就不会加载一些环境变量的 init 文件。&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Sat, 06 Oct 2018 00:13:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/37594</link>
      <guid>https://ruby-china.org/topics/37594</guid>
    </item>
    <item>
      <title>混合式开发的 App，在访问网页时，如何携带用户登录状态 (身份认证信息)？</title>
      <description>&lt;p&gt;现在有很多 APP 都是使用混合开发模式，其中 APP 登录一般都是使用原生开发的方式实现的，但是如果我在 APP 内需要访问一个需要登录用户才能访问的页面，
请问如果将用户登录状态（身份认证信息）通过 APP 内的 webview 发出的 HTTP 请求带到服务器？&lt;/p&gt;

&lt;p&gt;自己的解决方案：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;在需要登录的页面，用户访问的时候，通过 JS，使页面和 APP 进行通信，把用户的加密后的 session 写到 webview 的 cookie 中去，这样就自然完成了用户在页面的登陆过程，但是这个方法带来的问题是，app 如何处理用户的登出？一种做法是 APP 在用户登出的时候进行事件回调主动清除 webview 中的 cookies;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;APP 客户端对用户 webview 中的 HTTP 请求进行监听，如果发现是需要登录的页面，那么 APP 加密用户的认证信息，形成一个参数，然后将这个参数附加在 URL 中，这样该请求就会携带用户认证信息至服务器，完成用户认证的过程；&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;请问大家，你们一般用什么方案？这些方案的安全性如何？像京东、招商银行之类的 APP 也有这样的需求场景，请问这些大佬们一般用的是什么方法？&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Mon, 27 Aug 2018 16:50:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/37392</link>
      <guid>https://ruby-china.org/topics/37392</guid>
    </item>
    <item>
      <title>如何实现 “限制网页只在特定 APP 中打开”？</title>
      <description>&lt;p&gt;目标：实现也定的网页只能在自己开发的 APP 中打开，其他地方都不能打开该网页。
已知的方法有：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;判断请求 body 中的 UA；&lt;/li&gt;
&lt;li&gt;客户端重写 URL 请求 (例如：将 xxxx.com/a.html 的请求在客户端进行请求重定向至 xxx.com/b.html)&lt;/li&gt;
&lt;li&gt;客户端通过与 web page 的 js 交互，加密了一些信息，这些信息里面包括用户认证信息、时间戳之类的，然后将加密后的信息当成请求参数附加到请求 URL 中，当用户访问该 URL 时，服务器进行合法性校验；&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;第一种方法：简单，但是最容易 workaround，直接改写 UA 就行了；
第二种方法：通过对客户端的请求抓包，一样可以很容易的破解；
第三种方法：破解难度大一些而已，但是也不是绝对地不可破解。就算有时间戳限制，但是在时间戳范围内，页面请求的 URL 还是可以通过抓包直接打开&lt;/p&gt;

&lt;p&gt;请问大家有什么解决方案？像支付宝这种对安全性非常高的应用是采用的什么手段？&lt;/p&gt;</description>
      <author>flybee</author>
      <pubDate>Tue, 21 Aug 2018 17:38:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/37359</link>
      <guid>https://ruby-china.org/topics/37359</guid>
    </item>
  </channel>
</rss>
