<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>346617552 (小黑)</title>
    <link>https://ruby-china.org/346617552</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>请教 inverse_of 的作用</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Topic&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;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:counter_cache&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:inverse_of&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:topics&lt;/span&gt;
  &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ruby-Doc:
If you are using a belongs_to on the join model, it is a good idea to set the :inverse_of option on the belongs_to, which will mean that the following example works correctly (where tags is a has_many :through association):&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vi"&gt;@post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;
&lt;span class="vi"&gt;@tag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="vi"&gt;@post.tags.build&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"ruby"&lt;/span&gt;
&lt;span class="vi"&gt;@tag.save&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The last line ought to save the through record (a Taggable). This will only work if the :inverse_of is set:&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;Taggable&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;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:post&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:tag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:inverse_of&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:taggings&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;还是不太明白。。。&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Wed, 31 Oct 2012 12:50:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/6426</link>
      <guid>https://ruby-china.org/topics/6426</guid>
    </item>
    <item>
      <title>看 Rails Tutorial 这一段看得好晕。。。</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;SessionsHelper&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sign_in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:remember_token&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remember_token&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;current_user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;signed_in?&lt;/span&gt;
        &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;current_user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;nil?&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;current_user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="vi"&gt;@current_user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;current_user&lt;/span&gt;
        &lt;span class="vi"&gt;@current_user&lt;/span&gt; &lt;span class="o"&gt;||=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_by_remember_token&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:remember_token&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;def&lt;/span&gt; &lt;span class="nf"&gt;current_user?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;current_user&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sign_out&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;current_user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kp"&gt;nil&lt;/span&gt;
        &lt;span class="n"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:remember_token&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;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;判断一个 user 是不是 current_user 的时候，需要被判断的那个 user 不应该是个实例吗？&lt;/p&gt;

&lt;p&gt;一下有等号，一下没等号，一下有@一下没@，好晕。。。&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Tue, 30 Oct 2012 16:19:47 +0800</pubDate>
      <link>https://ruby-china.org/topics/6412</link>
      <guid>https://ruby-china.org/topics/6412</guid>
    </item>
    <item>
      <title>简单的来说 Engine 是什么？新手有必要掌握吗？</title>
      <description>&lt;p&gt;RT &amp;amp; THX&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Tue, 30 Oct 2012 00:51:07 +0800</pubDate>
      <link>https://ruby-china.org/topics/6398</link>
      <guid>https://ruby-china.org/topics/6398</guid>
    </item>
    <item>
      <title>嵌入在 css 里的 url 应该如何修改？</title>
      <description>&lt;p&gt;eg：&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.pxs_bg&lt;/span&gt; &lt;span class="nc"&gt;.pxs_bg1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="sx"&gt;url(../../images/slider/bg1.png)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;图片的实际地址为 app/assets/imgaes/slider/bg1.png&lt;/p&gt;

&lt;p&gt;请问 css 里的地址应该怎样改才能正确使用？&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Sat, 27 Oct 2012 16:47:10 +0800</pubDate>
      <link>https://ruby-china.org/topics/6358</link>
      <guid>https://ruby-china.org/topics/6358</guid>
    </item>
    <item>
      <title>求助:输入 git --version 后一直没有反映，是什么情况？</title>
      <description>&lt;p&gt;Mac 系统，Iterm 编辑器。&lt;/p&gt;

&lt;p&gt;之前 git 还好好的，不知弄了什么就没反映了。。。&lt;/p&gt;

&lt;p&gt;求助&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Mon, 22 Oct 2012 20:28:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/6245</link>
      <guid>https://ruby-china.org/topics/6245</guid>
    </item>
    <item>
      <title>请教在 vps 上搭建的问题</title>
      <description>&lt;p&gt;目前的状况：
1.借了个 vps 用，已经按照&lt;a href="http://ruby-china.org/wiki/install_ruby_guide" title=""&gt;如何快速正确的安装 Ruby, Rails 运行环境&lt;/a&gt;  &lt;a href="http://ruby-china.org/topics/701" title=""&gt;Passenger/Nginx/Ubuntu快速部署Rails 3.1&lt;/a&gt;  搭建了基础环境。&lt;/p&gt;

&lt;p&gt;2.用 rails new project 创建了一个新的项目&lt;/p&gt;

&lt;p&gt;3.启动了 rails 服务器&lt;/p&gt;

&lt;p&gt;可是通过 ip 地址打开网站，显示的是 Welcome to nginx！
由于之前一直是本地环境，现在换个 vps，就不知道该如何设置了。望指教。。。&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Sun, 21 Oct 2012 11:43:47 +0800</pubDate>
      <link>https://ruby-china.org/topics/6209</link>
      <guid>https://ruby-china.org/topics/6209</guid>
    </item>
    <item>
      <title>HHKB 静音化改造</title>
      <description>&lt;p&gt;看&lt;a href="/yedingding" class="user-mention" title="@yedingding"&gt;&lt;i&gt;@&lt;/i&gt;yedingding&lt;/a&gt; 发布的工作台展示的&lt;a href="http://call4review.com/c1113a" rel="nofollow" target="_blank" title=""&gt;帖子&lt;/a&gt;，貌似很多用 HHKB 的。&lt;/p&gt;

&lt;p&gt;可惜 HHKB 已经很贵了，结果 HHKB Type-S 更贵。。。贵了将近一千。&lt;/p&gt;

&lt;p&gt;对于 HHKB Pro2 在网上搜到一篇帖子，是对 HHKB 静音话改造的 DIY。感觉不错，分享下。十几块钱小造价看能不能折腾出几百块的效果来？&lt;/p&gt;

&lt;p&gt;转帖：&lt;a href="http://www.pcwaishe.cn/thread-415723-1-1.html" rel="nofollow" target="_blank" title=""&gt;HHKB Pro2 改造静音化实现 (自制 DIY type-s) &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PS：本人用茶轴，只是一周来一直被各种 hhkb 的帖子毒到。。。&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Thu, 18 Oct 2012 19:29:00 +0800</pubDate>
      <link>https://ruby-china.org/topics/6162</link>
      <guid>https://ruby-china.org/topics/6162</guid>
    </item>
    <item>
      <title>上次听到说 Github 对学生有优惠，可以免费两年的使用，有人知道怎么弄吗？</title>
      <description>&lt;p&gt;RT and thanks&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Thu, 11 Oct 2012 00:30:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/5983</link>
      <guid>https://ruby-china.org/topics/5983</guid>
    </item>
    <item>
      <title>9.2 The response Object 请求翻译</title>
      <description>&lt;p&gt;中文 Guides 里的一团乱，看不懂。那个长句看不懂了。
如果不吝惜指教的话，麻烦翻译一下下文，非常感谢。&lt;/p&gt;

&lt;p&gt;9.2 The response Object&lt;/p&gt;

&lt;p&gt;The response object is not usually used directly, but is built up during the execution of the action and rendering of the data that is being sent back to the user, but sometimes - like in an after filter - it can be useful to access the response directly. Some of these accessor methods also have setters, allowing you to change their values.&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Tue, 09 Oct 2012 23:27:15 +0800</pubDate>
      <link>https://ruby-china.org/topics/5951</link>
      <guid>https://ruby-china.org/topics/5951</guid>
    </item>
    <item>
      <title>“渲染 xml 和 json 数据” 不太懂</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationController&lt;/span&gt; &lt;span class="c1"&gt;#懂&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;   &lt;span class="c1"&gt;#懂&lt;/span&gt;
    &lt;span class="vi"&gt;@users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;    &lt;span class="c1"&gt;#懂&lt;/span&gt;
    &lt;span class="n"&gt;respond_to&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;   &lt;span class="c1"&gt;#不懂&lt;/span&gt;
      &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;html&lt;/span&gt; &lt;span class="c1"&gt;# index.html.erb&lt;/span&gt;
      &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xml&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;:xml&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@users&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;#不懂&lt;/span&gt;
      &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;:json&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@users&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;#不懂 百度JSON 太抽象了&lt;/span&gt;
    &lt;span class="k"&gt;end&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;p&gt;&lt;strong&gt;百度 XML：&lt;/strong&gt;
  XML 与 HTML 的设计区别是：XML 的核心是数据，其重点是数据的内容。而 HTML 被设计用来显示数据，其重点是数据的显示。
  XML 和 HTML 语法区别：HTML 的标记不是所有的都需要成对出现，XML 则要求所有的标记必须成对出现；HTML 标记不区分大小写，XML 则 大小敏感，即区分大小写。
结合
  XML 的简单使其易于在任何应用程序中读写数据，这使 XML 很快成为数据交换的唯一公共语言，虽然不同的应用软件也支持其它的数据交换格式，但不久之后他们都将支持 XML，那就意味着程序可以更容易的与 Windows,Mac OS,Linux 以及其他平台下产生的信息结合，然后可以很容易加载 XML 数据到程序中并分析他，并以 XML 格式输出结果。&lt;/p&gt;

&lt;p&gt;XML 具体是干嘛？ （可以形象点吗？）
在 Rails 的 MVC 架构中，哪里要用到？&lt;/p&gt;</description>
      <author>346617552</author>
      <pubDate>Tue, 09 Oct 2012 20:50:02 +0800</pubDate>
      <link>https://ruby-china.org/topics/5947</link>
      <guid>https://ruby-china.org/topics/5947</guid>
    </item>
  </channel>
</rss>
