<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>fan124 (fan124)</title>
    <link>https://ruby-china.org/fan124</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>关于 wicked_pdf + react 使用的问题</title>
      <description>&lt;p&gt;怎么才能用 &lt;code&gt;wicked_pdf_javascript_include_tag&lt;/code&gt; 获取 app/javascript/packs 下的 &lt;code&gt;application.js&lt;/code&gt;&lt;/p&gt;</description>
      <author>fan124</author>
      <pubDate>Wed, 25 Apr 2018 17:51:32 +0800</pubDate>
      <link>https://ruby-china.org/topics/35815</link>
      <guid>https://ruby-china.org/topics/35815</guid>
    </item>
    <item>
      <title>Activerecord 怎么实现 left join 的 on 后面加更多条件？</title>
      <description>&lt;p&gt;Activerecord 怎么实现 left join 的 on 后面加更多条件？&lt;br&gt;&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Maker&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;:cars&lt;/span&gt;

  &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="ss"&gt;:with_cars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;eager_load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&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;bolongs_to&lt;/span&gt; &lt;span class="ss"&gt;:maker&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
当我用 makers = Maker.with_cars 时有没有办法传参数给这个scope,
并且得到类似以下的SQL，我希望能给on多加几个条件

SELECT
     ....
FROM makers
LEFT OUTER JOIN cars
     ON makers.id = cars.maker_id
     AND cars.company_id = '我传的参数1'
     AND cars.status = '我传的参数2'
WHERE
     .....
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>fan124</author>
      <pubDate>Sun, 11 Jun 2017 00:30:33 +0800</pubDate>
      <link>https://ruby-china.org/topics/33207</link>
      <guid>https://ruby-china.org/topics/33207</guid>
    </item>
    <item>
      <title>formbuilder 可不可以生成不带 type 和 id 的 input </title>
      <description>&lt;p&gt;如题、有没有&amp;lt;%= f.xxxx %&amp;gt;&lt;br&gt;可以生成&amp;lt;input type=""&amp;gt;&lt;/p&gt;</description>
      <author>fan124</author>
      <pubDate>Wed, 17 May 2017 22:03:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/33011</link>
      <guid>https://ruby-china.org/topics/33011</guid>
    </item>
    <item>
      <title>关于 RSpec 测试</title>
      <description>&lt;p&gt;我刚开始学 RSpec 写测试，我发现 spec 目录下有好多目录，我从网上找资料发现，
从 Rails 5 和 RSpec 3.5 开始，不建议做 controller 的测试，而是做 feature 和 request 的测试&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;controllers&lt;/li&gt;
&lt;li&gt;features&lt;/li&gt;
&lt;li&gt;helpers&lt;/li&gt;
&lt;li&gt;mailers&lt;/li&gt;
&lt;li&gt;models&lt;/li&gt;
&lt;li&gt;requests&lt;/li&gt;
&lt;li&gt;routing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这几个当中，我是不是可以不写 controllers，还有 features（用 Capybara 做）可以覆盖 requests 和 routing，所以这俩（requests，routing）是不是可以不做？&lt;/p&gt;</description>
      <author>fan124</author>
      <pubDate>Tue, 18 Apr 2017 16:24:13 +0800</pubDate>
      <link>https://ruby-china.org/topics/32813</link>
      <guid>https://ruby-china.org/topics/32813</guid>
    </item>
    <item>
      <title>关于 utility</title>
      <description>&lt;p&gt;我在网上和书上查到 Utility 应该放到/lib 下
那 Utility 应该是个 Module，然后在每个 class 使用时 include 进来呢？
还是是个 Class，每个方法都带 self，在其他 class 里直接使用呢？&lt;/p&gt;</description>
      <author>fan124</author>
      <pubDate>Sun, 20 Nov 2016 13:40:50 +0800</pubDate>
      <link>https://ruby-china.org/topics/31643</link>
      <guid>https://ruby-china.org/topics/31643</guid>
    </item>
    <item>
      <title>请问 js,css 文件应该怎么 include 进来？</title>
      <description>&lt;p&gt;我知道 application.js 和 application.css 里只要有 require_tree .
执行时就可以把所有资源文件 include 进来，&lt;/p&gt;

&lt;p&gt;但是这是个推荐的做法吗？
因为我觉得每个 view 不需要把所有资源文件都 include 进来，&lt;/p&gt;

&lt;p&gt;是不是每个 view 加上 content_for :scripts 各自 include 自己需要的 js,css
而共用的在 application.js 和 application.css 里列出来？&lt;/p&gt;

&lt;p&gt;有什么最佳实践吗？
我是新手，请多关照^_^&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;=========================================================&lt;/li&gt;
&lt;li&gt;新手问题 2&lt;/li&gt;
&lt;li&gt;如果把 js 代码都写到 js 文件里了，在 js 文件里怎么使用 helper?&lt;/li&gt;
&lt;li&gt;直接在 js.erb 用 helper 会报错，我知道在 assets.rb 里这样配置是可以的&lt;/li&gt;
&lt;li&gt;Sprockets::Context.send :include, Rails.application.routes.url_helpers&lt;/li&gt;
&lt;li&gt;Sprockets::Context.send :include, WelcomeHelper&lt;/li&gt;
&lt;li&gt;但是每个 helper 都要这样配置吗？&lt;/li&gt;
&lt;li&gt;有没有更好的办法？&lt;/li&gt;
&lt;li&gt;&lt;p&gt;还有就是 js.erb 里使用 helper 这种做法有不妥的地方吗？&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;=========================================================&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;补充&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;%= javascript_include_tag params[:controller] %&amp;gt;这个东西还是不可取，因为如果是 render 指定过来的 view 的 controller 名不一定是我想要的&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <author>fan124</author>
      <pubDate>Thu, 17 Nov 2016 19:50:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/31622</link>
      <guid>https://ruby-china.org/topics/31622</guid>
    </item>
  </channel>
</rss>
