<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Runable (root)</title>
    <link>https://ruby-china.org/Runable</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>我的项目原本是 Rails 6.0.0 beta2, 我现在要把 Rails 版本降到 5.2.2</title>
      <description>&lt;p&gt;但是现在出问题了，一些文件 require 不到
&lt;img src="https://l.ruby-china.com/photo/2019/21638ad8-6c03-42ce-87f0-1bdc9d5e1061.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>Runable</author>
      <pubDate>Fri, 29 Mar 2019 17:26:35 +0800</pubDate>
      <link>https://ruby-china.org/topics/38313</link>
      <guid>https://ruby-china.org/topics/38313</guid>
    </item>
    <item>
      <title>使用 accepts_nested_attributes_for 去 update 一对多的嵌套表，为什么 update 变成了 insert</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;
  &lt;span class="vi"&gt;@diary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;Diary&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="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vi"&gt;@diary.update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update_diary_params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;render_ok&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="n"&gt;render_err&lt;/span&gt; &lt;span class="ss"&gt;:update_error&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;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update_diary_params&lt;/span&gt;
  &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:diary&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;permit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:weather&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:remark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:diary_pictures_attributes&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;:diary_picture&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:clothing_picture&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:_destroy&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;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Diary&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:diary_pictures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;dependent: :destroy&lt;/span&gt;

  &lt;span class="n"&gt;accepts_nested_attributes_for&lt;/span&gt; &lt;span class="ss"&gt;:diary_pictures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;allow_destroy: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DiaryPicture&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:diary&lt;/span&gt;
  &lt;span class="n"&gt;validates_presence_of&lt;/span&gt; &lt;span class="ss"&gt;:diary&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2019/b02234c3-ee48-4c46-a4bd-97a74ce29df1.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>Runable</author>
      <pubDate>Fri, 15 Mar 2019 22:52:07 +0800</pubDate>
      <link>https://ruby-china.org/topics/38238</link>
      <guid>https://ruby-china.org/topics/38238</guid>
    </item>
    <item>
      <title>项目有一个报错 Errno::EACCES: Permission denied @ rb_file_s_symlink -</title>
      <description>&lt;p&gt;怎么解决权限的问题，一直 bundle 不成功
&lt;img src="https://l.ruby-china.com/photo/2018/ac971054-d264-4255-9cc7-65b94698fad6.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>Runable</author>
      <pubDate>Thu, 13 Sep 2018 16:27:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/37482</link>
      <guid>https://ruby-china.org/topics/37482</guid>
    </item>
    <item>
      <title>请问如何写成下面这个 json 的 API？</title>
      <description>&lt;p&gt;下面是数据库的图片和要怎么写成下面的 json 的 API
&lt;img src="https://l.ruby-china.com/photo/2018/64b3cf35-9dff-4220-a76f-33b793764879.png!large" title="" alt=""&gt;&lt;/p&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
    &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;product_category&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"坐具"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;椅子，&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;沙发，&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;product_category&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"桌子"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"书桌"&lt;/span&gt;&lt;span class="err"&gt;，&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"案几"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"茶几"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"餐桌"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;

        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>Runable</author>
      <pubDate>Tue, 07 Aug 2018 10:37:42 +0800</pubDate>
      <link>https://ruby-china.org/topics/37294</link>
      <guid>https://ruby-china.org/topics/37294</guid>
    </item>
    <item>
      <title>请问如何在匹配一个数字在一个数字数组中存在</title>
      <description>&lt;p&gt;请问如何在匹配一个数字在一个数字数组中存在，或者说一个数组怎么判断包含另外一个数组&lt;/p&gt;</description>
      <author>Runable</author>
      <pubDate>Mon, 06 Aug 2018 14:39:28 +0800</pubDate>
      <link>https://ruby-china.org/topics/37288</link>
      <guid>https://ruby-china.org/topics/37288</guid>
    </item>
  </channel>
</rss>
