<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>seeyoup</title>
    <link>https://ruby-china.org/seeyoup</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>ruby 布尔类型判断迷惑中</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"空字符串&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"空数组"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kp"&gt;nil&lt;/span&gt;
  &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s1"&gt;'nil'&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
  &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'有名额1'&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'没有明额0'&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;测试了这么多，只有 if true 和 if false 感觉判断准确，其他''、0、[]，为什么条件判断的时候都成立了，这样的话，我如何判断数据是否为空呢？&lt;/p&gt;</description>
      <author>seeyoup</author>
      <pubDate>Wed, 20 Aug 2014 23:42:50 +0800</pubDate>
      <link>https://ruby-china.org/topics/21145</link>
      <guid>https://ruby-china.org/topics/21145</guid>
    </item>
    <item>
      <title>Rails 4 + Ruby 2.0 自学书籍</title>
      <description>&lt;p&gt;本人也是 rails 初学者，希望共勉，感谢作者。
下载地址：
&lt;a href="http://pan.baidu.com/s/1mg9fKX6" rel="nofollow" target="_blank"&gt;http://pan.baidu.com/s/1mg9fKX6&lt;/a&gt;&lt;/p&gt;</description>
      <author>seeyoup</author>
      <pubDate>Fri, 06 Jun 2014 11:09:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/19780</link>
      <guid>https://ruby-china.org/topics/19780</guid>
    </item>
    <item>
      <title>使用 paperclip 无法将路径保存到对应的字段中</title>
      <description>&lt;p&gt;以下是我的 model 配置，并已经可以通过 controller 上传到指定的目录，可就是打开数据库发现字段 img_path 和其他几个字段都是空的，只有 title 我输入的有内容，百度了一个早上还是没有解决，请大师们给看看。谢谢。
版本：rails3.2,paperclip 是最新版
环境：mac 和 windows 都不保存不了路径到数据库&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;#coding: utf-8&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Photo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
  &lt;span class="n"&gt;attr_accessible&lt;/span&gt; &lt;span class="ss"&gt;:img_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:is_verify&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:title&lt;/span&gt;
  &lt;span class="nb"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:img_path_file_name&lt;/span&gt;
  &lt;span class="nb"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:img_path_content_type&lt;/span&gt;
  &lt;span class="nb"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:img_path_file_size&lt;/span&gt;
  &lt;span class="nb"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:img_path_updated_at&lt;/span&gt;
  &lt;span class="n"&gt;has_attached_file&lt;/span&gt; &lt;span class="ss"&gt;:img_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="ss"&gt;:styles&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;:thumb&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"200x200&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:mini&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"100x100&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:medium&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"400x400&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:large&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"600x600&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
                    &lt;span class="ss"&gt;:default_url&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"/images/:style/missing.png"&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;"/uploads/pics/:id/:id_:style.:extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="ss"&gt;:path&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;":rails_root/public/uploads/pics/:id/:id_:style.:extension"&lt;/span&gt;
  &lt;span class="n"&gt;validates_attachment_content_type&lt;/span&gt; &lt;span class="ss"&gt;:img_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:content_type&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="s1"&gt;'image/gif'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/x-png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/jpeg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/pjpeg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image/jpg'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;打开 log 有日志，发现插入的都为 nil:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO "photos" ("created_at", "img_path", "img_path_content_type", "img_path_file_name", "img_path_file_size", "img_path_updated_at", "is_verify", "title", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)  [["created_at", Fri, 05 Jul 2013 11:22:48 CST +08:00], ["img_path", nil], ["img_path_content_type", nil], ["img_path_file_name", nil], ["img_path_file_size", nil], ["img_path_updated_at", nil], ["is_verify", nil], ["title", "vvvv"], ["updated_at", Fri, 05 Jul 2013 11:22:48 CST +08:00]]

&lt;/code&gt;&lt;/pre&gt;</description>
      <author>seeyoup</author>
      <pubDate>Fri, 05 Jul 2013 11:41:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/12265</link>
      <guid>https://ruby-china.org/topics/12265</guid>
    </item>
    <item>
      <title>rake test:benchmark 测试总是报错</title>
      <description>&lt;p&gt;我创建了一个基本的应用，控制器 news，默认 root 为"news/index"，使用
&lt;a href="http://localhost:3000/" rel="nofollow" target="_blank"&gt;http://localhost:3000/&lt;/a&gt;可以直接访问到新闻：&lt;/p&gt;
&lt;h2 id="在test/performance中新建了homepage_test.rb"&gt;在 test/performance 中新建了 homepage_test.rb&lt;/h2&gt;
&lt;p&gt;require 'test_helper'
require 'rails/performance_test_help'&lt;/p&gt;

&lt;p&gt;class HomepageTest &amp;lt; ActionDispatch::PerformanceTest
  # Refer to the documentation for all available options
  # self.profile_options = { :runs =&amp;gt; 5, :metrics =&amp;gt; [:wall_time, :memory]
  #                          :output =&amp;gt; 'tmp/performance', :formats =&amp;gt; [:flat] }&lt;/p&gt;

&lt;p&gt;def test_homepage
    get '/'
  end&lt;/p&gt;
&lt;h2 id="end"&gt;end&lt;/h2&gt;
&lt;p&gt;在应用程序目录运行
rake test:benchmark
总是报错，不知道问题出在哪里了。&lt;/p&gt;

&lt;p&gt;Specify ruby-prof as application's dependency in Gemfile to run benchmarks.&lt;/p&gt;</description>
      <author>seeyoup</author>
      <pubDate>Mon, 22 Apr 2013 07:49:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/10391</link>
      <guid>https://ruby-china.org/topics/10391</guid>
    </item>
  </channel>
</rss>
