<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>a4652097 (龙飞)</title>
    <link>https://ruby-china.org/a4652097</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>求教 passenger 无法启动问题</title>
      <description>&lt;p&gt;参考了&lt;a href="https://ruby-china.org/topics/36899" rel="nofollow" target="_blank"&gt;https://ruby-china.org/topics/36899&lt;/a&gt;进行代码部署&lt;/p&gt;

&lt;p&gt;项目 ruby 版本 2.7.1  rails 版本 5.0.7&lt;/p&gt;

&lt;p&gt;执行&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cap staging deploy
The deploy has failed with an error: Exception while executing as deploy@101.200.221.104: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:

 1. You customized the instance registry directory using Apache's
    PassengerInstanceRegistryDir option, Nginx's
    passenger_instance_registry_dir option, or Phusion Passenger Standalone's
    --instance-registry-dir command line argument. If so, please set the
    environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
    and run this command again.
 2. The instance directory has been removed by an operating system background
    service. Please set a different instance registry directory using Apache's
    PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
    option, or Phusion Passenger Standalone's --instance-registry-dir command
    line argument.


&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;返回我 Passenger 没有启动&lt;/p&gt;

&lt;p&gt;去到服务器上&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  ps aux | grep flying-passenger
deploy   31557  0.0  0.0  16192  1080 pts/0    S+   22:19   0:00 grep --color=auto flying-passenger
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;再执行一下&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ passenger-status
Traceback (most recent call last):
    2: from /usr/local/bin/passenger-status:23:in `&amp;lt;main&amp;gt;'
    1: from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem passenger (&amp;gt;= 0.a) with executable passenger-status (Gem::GemNotFoundException)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;未找到 passenger。。。&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ which passenger-config
/usr/local/bin/passenger-config
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;也是能找到的。&lt;/p&gt;

&lt;p&gt;请问这个是什么问题？passenger 我确实也安装了。&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Sun, 24 May 2020 22:23:37 +0800</pubDate>
      <link>https://ruby-china.org/topics/39895</link>
      <guid>https://ruby-china.org/topics/39895</guid>
    </item>
    <item>
      <title>安装 Rails 出现 cannot load such file -- openssl</title>
      <description>&lt;p&gt;ruby 版本是 2.3.0，mac os x 是 10.13.6 &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin17]

$ gem install rails -v 3.2.16
ERROR:  Loading command: install (LoadError)
    cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;执行 gem install rails -v 3.2.16，安装 rails 出现 openssl 问题，
参考了一下&lt;a href="https://ruby-china.org/topics/8966" rel="nofollow" target="_blank"&gt;https://ruby-china.org/topics/8966&lt;/a&gt;的解决方案，
尝试安装 openssl&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brew install openssl
Warning: openssl@1.1 1.1.1g is already installed and up-to-date
To reinstall 1.1.1g, run `brew reinstall openssl@1.1`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;已经是最新的 openssl，继续尝试 rvm pkg install openssl
给出如下错误&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brew install openssl
Beware, 'rvm pkg ...' is deprecated, read about the new autolibs feature: 'rvm help autolibs'.

Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Fetching openssl-1.0.1i.tar.gz to /Users/alan/.rvm/archives
Extracting openssl to /Users/alan/.rvm/src/openssl-1.0.1i.....
Configuring openssl in /Users/alan/.rvm/src/openssl-1.0.1i.....................-
Compiling openssl in /Users/alan/.rvm/src/openssl-1.0.1i.......................|
Installing openssl to /Users/alan/.rvm/usr.....................................-
Error running '__rvm_make install',
please read /Users/alan/.rvm/log/1589712289/openssl_make.install.log

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Updating openssl certificates.......
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;继续尝试 rvm reinstall all 命令后还是错误，请问这个是什么问题？&lt;/p&gt;

&lt;p&gt;也尝试过重新安装 ruby，出现&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error running 'env GEM_HOME=/Users/alan/.rvm/gems/ruby-2.3.0@global GEM_PATH= /Users/alan/.rvm/rubies/ruby-2.3.0/bin/ruby -d /Users/alan/.rvm/src/rubygems-3.0.8/setup.rb --no-document',
please read /Users/alan/.rvm/log/1589713192_ruby-2.3.0/rubygems.install.log
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>a4652097</author>
      <pubDate>Sun, 17 May 2020 18:49:01 +0800</pubDate>
      <link>https://ruby-china.org/topics/39879</link>
      <guid>https://ruby-china.org/topics/39879</guid>
    </item>
    <item>
      <title>关于一个 model 的怪问题</title>
      <description>&lt;p&gt;这是我的 model&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Equipment::Accepting &amp;lt; ApplicationRecord
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这是我的 controller&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Api::App::Equipment::AcceptingsController &amp;lt; Api::App::ApplicationController
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;当我在我的 controller 里调用 Equipment::Accepting 时，会告诉我&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=&amp;gt;NameError: uninitialized constant Api::App::Equipment::AcceptingsController::Equipment
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后我试着在 console 里调用 Equipment::Accepting&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=&amp;gt;Equipment::Accepting (call 'Equipment::Accepting.connection' to establish a connection)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;成功了。然后我试着创建一些新的 model，然后在 controller 里调用 Approval::Flow&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=&amp;gt; Approval::Flow(id: integer, apply_id: integer, timestamp: datetime, to_id: integer, message: string, pass: boolean, is_sync: boolean, code: string, created_at: datetime, updated_at: datetime)

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;很奇怪的一个问题，尝试了许多办法。能给我指点一下的话，不胜感激。&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Sat, 14 Apr 2018 16:43:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/35454</link>
      <guid>https://ruby-china.org/topics/35454</guid>
    </item>
    <item>
      <title>Java 的 RSA 加密算法规则如何用 Ruby 改写呢？</title>
      <description>&lt;p&gt;JAVA 代码&lt;/p&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * 
 * 将通过Base64编码后的String类型的私钥字符串转换为PrivateKey对象
 * 
 * @param strPriKey Base64编码后的String类型的私钥字符串
 * @return
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 * @since 10.15
 */&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;PrivateKey&lt;/span&gt; &lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;strPriKey&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;InvalidKeySpecException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;PKCS8EncodedKeySpec&lt;/span&gt; &lt;span class="n"&gt;priKeySpec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PKCS8EncodedKeySpec&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;decodeBase64&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strPriKey&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
    &lt;span class="nc"&gt;KeyFactory&lt;/span&gt; &lt;span class="n"&gt;keyFactory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;KeyFactory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInstance&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;RSA&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;PrivateKey&lt;/span&gt; &lt;span class="n"&gt;priKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;keyFactory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;generatePrivate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;priKeySpec&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;priKey&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后进行 RSA 签名&lt;/p&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * 
 * RSA签名:
 * 
 * @param data 请求原文
 * @param prik 私钥
 * @return 签名值
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeyException
 * @throws SignatureException
 * @since 10.15
 */&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PrivateKey&lt;/span&gt; &lt;span class="n"&gt;prik&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;InvalidKeyException&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;SignatureException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Signature&lt;/span&gt; &lt;span class="n"&gt;signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Signature&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInstance&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SHA1_WITH_RSA&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initSign&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prik&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * 
 * RSA签名
 * 
 * @param data 请求原文
 * @param prik 私钥
 * @return
 * @throws InvalidKeyException
 * @throws NoSuchAlgorithmException
 * @throws SignatureException
 * @see [相关类/方法](可选)
 * @since [产品/模块版本](可选)
 */&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PrivateKey&lt;/span&gt; &lt;span class="n"&gt;prik&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;InvalidKeyException&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;NoSuchAlgorithmException&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;SignatureException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;encodeBase64String&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getBytes&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;prik&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;();&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 java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// (1).获取加签私钥      &lt;/span&gt;
&lt;span class="nc"&gt;PrivateKey&lt;/span&gt; &lt;span class="n"&gt;prik&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RSAUtil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getPrivateKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;商户私钥字符串&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// (2).排除不参与加签的字段。生成摘要明文 params = Digest.treeMap(params, "sign_type","signkey_index"); &lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;digestData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Digest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;mapToString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// (3).对摘要明文进行MD5摘要      digestData = MD5.digest(digestData, "utf-8"); &lt;/span&gt;
&lt;span class="c1"&gt;// (4).传入摘要密文和私钥，进行加签 &lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RSAUtil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digestData&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prik&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// (5). 进行urlEncode编码      &lt;/span&gt;
&lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;URLEncoder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;encode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// (6). 将加签后的sign放入请求参数中     &lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sign"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sign&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;试着用 ruby 的方式写出来&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;key&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="s1"&gt;'lib/suning_cert/rsa_private_key.pem'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rsa&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;OpenSSL&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;PKey&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;RSA&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="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Digest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;MD5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;upcase&lt;/span&gt;
&lt;span class="n"&gt;sign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="no"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strict_encode64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rsa&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;force_encoding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;最后得到的签名没有通过平台的验签。是需要把私钥转化为 PrivateKey 对象么，我不太清楚 java 怎么做的。就不知道如何改写了。。。&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Mon, 11 Dec 2017 17:13:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/34690</link>
      <guid>https://ruby-china.org/topics/34690</guid>
    </item>
    <item>
      <title>CarrierWave Multiple file uploads 多张图片上传时遇到上传的图片变成同一张图片</title>
      <description>&lt;p&gt;我是直接把文件储存到了 public 下，在本地运行是可以的。但是在服务器上运行的话就会出现上传多张不同的图片后，储存的时候变成储存同一张图片了。&lt;/p&gt;

&lt;p&gt;我上传了两张图片查看服务器日志
这个是参数&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Parameters: {"utf8"=&amp;gt;"✓", "authenticity_token"=&amp;gt;"+4HZifzZy2Alps2IzQ2VdCa83CduJaV+syos6JgEjQaFFokk7e2Menrr/jltEObenLEwuy9NxA4pYwbQuLEzEA==", "report"=&amp;gt;{"app_photos"=&amp;gt;[#&amp;lt;ActionDispatch::Http::UploadedFile:0x007fa302be4270 @tempfile=#&amp;lt;Tempfile:/var/folders/9g/qs8svjp97ydgzqzhbhxpthhc0000gn/T/RackMultipart20151231-33133-18p6wl3.jpg&amp;gt;, @original_filename="87fb7227dce3653a297525ffd2a12fd2.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"report[app_photos][]\"; filename=\"87fb7227dce3653a297525ffd2a12fd2.jpg\"\r\nContent-Type: image/jpeg\r\n"&amp;gt;, #&amp;lt;ActionDispatch::Http::UploadedFile:0x007fa302be4248 @tempfile=#&amp;lt;Tempfile:/var/folders/9g/qs8svjp97ydgzqzhbhxpthhc0000gn/T/RackMultipart20151231-33133-srb0n4.jpg&amp;gt;, @original_filename="520900d78c47f.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"report[app_photos][]\"; filename=\"520900d78c47f.jpg\"\r\nContent-Type: image/jpeg\r\n"&amp;gt;]}, "commit"=&amp;gt;"上传中", "sale_id"=&amp;gt;"1", "id"=&amp;gt;"8"}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这个是添加语句&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO `reports` (`app_photos`, `sale_id`, `meeting_id`, `created_at`, `updated_at`) VALUES ('[\"38060cf588c242abbfab8eb523c593dd.jpg\",\"38060cf588c242abbfab8eb523c593dd.jpg\"]', 1, 8, '2015-12-31 03:49:22', '2015-12-31 03:49:22')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;参数是正确的，可是这里变成同一个文件名了。
代码里
controller&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def params_reports
params.require(:user).permit({app_photos: []})
end
&lt;/code&gt;&lt;/pre&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def create_phots
    @reports = Report.new(params_reports)
    @reports.save
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;model&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Report &amp;lt; ActiveRecord::Base
  attr_accessor :uploader_secure_token
  mount_uploaders :app_photos, AvatarUploader
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这个是我的 AvatarUploader&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'carrierwave/processing/mini_magick'
# 在图片空间里面定义好的“缩略图版本名称”，以防止调用错误
IMAGE_UPLOADER_ALLOW_IMAGE_VERSION_NAMES = %(20x20 30x30 240x240 100x100 120x90 160x120 250x187 320 640 800)
class AvatarUploader &amp;lt; CarrierWave::Uploader::Base
  def store_dir
    "#{model.class.to_s.underscore}/#{mounted_as}"
  end

  def default_url
    # 搞一个大一点的默认图片取名 blank.png 用 FTP 传入图片空间，用于作为默认图片
    # 由于有自动的缩略图处理，小图也不成问题
    # Setting.upload_url 这个是你的图片空间 URL
    "#{Setting.upload_url}/blank.png#{version_name}"
  end

  # 覆盖 url 方法以适应“图片空间”的缩略图命名
  def url(version_name = "")
    @url ||= super({})
    version_name = version_name.to_s
    return @url if version_name.blank?
    if not version_name.in?(IMAGE_UPLOADER_ALLOW_IMAGE_VERSION_NAMES)
      # 故意在调用了一个没有定义的“缩略图版本名称”的时候抛出异常，以便开发的时候能及时看到调错了
      raise "ImageUploader version_name:#{version_name} not allow."
    end
    [@url,version_name].join("!") # 我这里在图片空间里面选用 ! 作为“间隔标志符”
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end

  def filename
    if super.present?
      model.uploader_secure_token ||= SecureRandom.uuid.gsub("-","")
      Rails.logger.debug("(BaseUploader.filename) #{model.uploader_secure_token}")
      "#{model.uploader_secure_token}.#{file.extension.downcase}"
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;bug 找了半天 google 后也没有发现出现过我这种问题，所以只好来 rubychina 来问问各位大神了。&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Thu, 31 Dec 2015 12:16:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/28578</link>
      <guid>https://ruby-china.org/topics/28578</guid>
    </item>
    <item>
      <title>电脑中了毒啊，打开谷歌浏览器不是跳爱淘宝，就是跳 hao123!</title>
      <description>&lt;p&gt;我日！所有电脑都这样! 是不是 ip 被攻击了！&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Thu, 22 Jan 2015 10:04:34 +0800</pubDate>
      <link>https://ruby-china.org/topics/23871</link>
      <guid>https://ruby-china.org/topics/23871</guid>
    </item>
    <item>
      <title>如何修改 paperclip 的文件上传提示</title>
      <description>&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2015/147b9adf7374c4a2872e11d1468ce21b.png" title="" alt=""&gt;
当上传完成后，再次打开该页面，会显示“没有文件”的提示文字，如何让他显示已上传的文件名呢？&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Tue, 20 Jan 2015 14:29:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/23833</link>
      <guid>https://ruby-china.org/topics/23833</guid>
    </item>
    <item>
      <title>能不能把项目里的默认文字都改成微软雅黑?</title>
      <description>&lt;p&gt;求解？&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Mon, 19 Jan 2015 14:18:42 +0800</pubDate>
      <link>https://ruby-china.org/topics/23809</link>
      <guid>https://ruby-china.org/topics/23809</guid>
    </item>
    <item>
      <title>搜索框里放一个放大镜的背景图片,如何能点击他调用搜索功能呢?</title>
      <description>&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search_field&lt;/span&gt; &lt;span class="ss"&gt;:order_num_or_receipt_receipt_phone_cont&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:placeholder&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"搜索手机号/商品货号"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s1"&gt;'form-control'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:style&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"background:url(/assets/common_admin/order/search_ico.png) no-repeat right center;background-color: #ffffff;"&lt;/span&gt;&lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;文本框代码如上。图片设置为背景图片就不能选择这个放大镜的元素调用 click 事件了，,问问有没有什么高招没&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Fri, 16 Jan 2015 11:44:01 +0800</pubDate>
      <link>https://ruby-china.org/topics/23774</link>
      <guid>https://ruby-china.org/topics/23774</guid>
    </item>
    <item>
      <title>CKEditor 在服务器上上传图片只能传 3 张?</title>
      <description>&lt;p&gt;在服务器上最多只能上传 3 张图片，3 张以上就会报错。本地上是没有限制.求解！&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Wed, 14 Jan 2015 21:20:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/23742</link>
      <guid>https://ruby-china.org/topics/23742</guid>
    </item>
    <item>
      <title>请教批量导出怎么写</title>
      <description>&lt;p&gt;求方法地址，我自己看去&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Tue, 23 Dec 2014 12:08:26 +0800</pubDate>
      <link>https://ruby-china.org/topics/23354</link>
      <guid>https://ruby-china.org/topics/23354</guid>
    </item>
    <item>
      <title>[小白求教] 导入 excel 该怎么写?</title>
      <description>&lt;p&gt;有没有教程什么的文档啥的 我自己去看，&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Thu, 18 Dec 2014 10:52:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/23264</link>
      <guid>https://ruby-china.org/topics/23264</guid>
    </item>
    <item>
      <title>请教 Ransack 简单搜索</title>
      <description>&lt;p&gt;view&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;div&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'col-xs-2'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= f.search_field :order_num_or_order_type_text_cont, :placeholder=&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"搜索客人手机号/交易商品货号"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"search_text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;class: &lt;/span&gt;&lt;span class="s2"&gt;"form-control"&lt;/span&gt;&lt;span class="o"&gt;%&amp;gt;&lt;/span&gt;    
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;undefined method `order_num_or_order_type_text_cont' for #&lt;a rel="nofollow" target="_blank"&gt;Ransack::Search:0x0000000585d950&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;为什么会错误呢&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Wed, 17 Dec 2014 14:43:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/23248</link>
      <guid>https://ruby-china.org/topics/23248</guid>
    </item>
    <item>
      <title>谷歌能用了!</title>
      <description>&lt;p&gt;不用翻墙也能上了！这算是好消息吗&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Mon, 15 Dec 2014 17:08:28 +0800</pubDate>
      <link>https://ruby-china.org/topics/23210</link>
      <guid>https://ruby-china.org/topics/23210</guid>
    </item>
    <item>
      <title>关于多选数据修改</title>
      <description>&lt;p&gt;我有一张 orders 表，有一个全选功能，我全选或者自由选择后，再对此订单进行操作该怎么写呢？&lt;/p&gt;

&lt;p&gt;页面&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= check_box_tag "check_box","check" %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;order_num&lt;/span&gt; &lt;span class="sx"&gt;%&amp;gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"dropdown"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%=link_to "#",:class=&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"dropdown-toggle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:data&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;:toggle&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"dropdown"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="sx"&gt;%&amp;gt;
        订单操作 &amp;lt;b class="caret"&amp;gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/b&amp;gt;
      &amp;lt;ul class="dropdown-menu"&amp;gt;
        &amp;lt;li&amp;gt;
          &amp;lt;%=link_to "支付", payment_admin_order_path(order.id)%&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%=link_to "发货", deliver_good_admin_order_path(order.id)%&amp;gt;&amp;lt;/li&amp;gt;

        &amp;lt;li&amp;gt;&amp;lt;%=&lt;/span&gt;&lt;span class="n"&gt;link_to&lt;/span&gt; &lt;span class="s2"&gt;"完成"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order_state_admin_order_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&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="o"&gt;%&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&amp;gt;

        &amp;lt;li&amp;gt;
          &amp;lt;%=link_to "取消", to_void_admin_order_path(order.id)%&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&amp;gt;
      &amp;lt;% end %&amp;gt;  
  &amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;        
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>a4652097</author>
      <pubDate>Mon, 08 Dec 2014 16:26:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/23086</link>
      <guid>https://ruby-china.org/topics/23086</guid>
    </item>
    <item>
      <title>关于引用地址问题</title>
      <description>&lt;p&gt;代码如下
&lt;code&gt;span.badge = article.comment.content&lt;/code&gt;
报错：
&lt;strong&gt;undefined method `content' for #&lt;a rel="nofollow" target="_blank"&gt;Comment::ActiveRecord_Associations_CollectionProxy:0x007fe9f46ca4e0&lt;/a&gt;&lt;/strong&gt;
什么问题呢？&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Tue, 14 Oct 2014 14:19:16 +0800</pubDate>
      <link>https://ruby-china.org/topics/22032</link>
      <guid>https://ruby-china.org/topics/22032</guid>
    </item>
    <item>
      <title>问问大家用富文本时有没有碰到过这个问题</title>
      <description>&lt;p&gt;我用的是 kindeditor 这个富文本编辑，进入编辑页面时候，需要刷新一次才能在里面输入内容。怎么解决？或者怎么让浏览器默认刷新一次？&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Thu, 09 Oct 2014 15:44:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/21943</link>
      <guid>https://ruby-china.org/topics/21943</guid>
    </item>
    <item>
      <title>ruby 里双引号和单引号有什么区别</title>
      <description>&lt;p&gt;如题&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Sun, 28 Sep 2014 16:09:15 +0800</pubDate>
      <link>https://ruby-china.org/topics/21763</link>
      <guid>https://ruby-china.org/topics/21763</guid>
    </item>
    <item>
      <title>文章内容的文本编辑器怎么搞？</title>
      <description>&lt;p&gt;用 text_area 的话，文章显示时都不换行。就想问下，有什么强大的文本编辑就像下面这样的&lt;img src="https://l.ruby-china.com/photo/2014/925cc5e81155d9dbe1e9e683f995a73e.jpg" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Mon, 22 Sep 2014 13:47:07 +0800</pubDate>
      <link>https://ruby-china.org/topics/21657</link>
      <guid>https://ruby-china.org/topics/21657</guid>
    </item>
    <item>
      <title>请问根据另一张表的 ID 查询这张表的数据该如何分页</title>
      <description>&lt;p&gt;如下：
直接查询的话是这样：    &lt;a href="/article" class="user-mention" title="@article"&gt;&lt;i&gt;@&lt;/i&gt;article&lt;/a&gt; = Article.paginate(:page =&amp;gt; params[:page], :per_page =&amp;gt; 5).reorder(created_at: :desc)
页面上写    = will_paginate &lt;a href="/article" class="user-mention" title="@article"&gt;&lt;i&gt;@&lt;/i&gt;article&lt;/a&gt;, renderer: BootstrapPagination::Rails
&lt;strong&gt;那么我要根据分类表的 ID 查询所得的文章该如何分页？&lt;/strong&gt;
&lt;a href="/category" class="user-mention" title="@category"&gt;&lt;i&gt;@&lt;/i&gt;category&lt;/a&gt; = Category.find(params[:id])&lt;/p&gt;</description>
      <author>a4652097</author>
      <pubDate>Fri, 19 Sep 2014 13:37:17 +0800</pubDate>
      <link>https://ruby-china.org/topics/21609</link>
      <guid>https://ruby-china.org/topics/21609</guid>
    </item>
  </channel>
</rss>
