<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>hynmath</title>
    <link>https://ruby-china.org/hynmath</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>这种 URL 如何实现</title>
      <description>&lt;p&gt;Project 模型有 namespace (所在空间), 以及 name (项目名称) 两个属性。定义 Project 的 to_param 方法如下&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def to_param
  namespace.name + "/" + name
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;假设 &lt;a href="/project" class="user-mention" title="@project"&gt;&lt;i&gt;@&lt;/i&gt;project&lt;/a&gt; 是一个 Project 对象，所在空间的名称为 &lt;code&gt;ruby&lt;/code&gt;, 而 project 的名称为 &lt;code&gt;rails&lt;/code&gt;. &lt;code&gt;@project.to_param&lt;/code&gt; 确实能输出 &lt;code&gt;ruby/rails&lt;/code&gt;; 但是在路由帮助方法中，比如 &lt;code&gt;project_path(@project)&lt;/code&gt;, 却变成了 &lt;code&gt;ruby%2Frails&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;这肯定是发生了转义，但我不要它转义，保留原来的样式，请问我该怎么做？&lt;/p&gt;

&lt;p&gt;我已在网上搜索解决方法，但无果，请各位大侠帮帮忙^_^&lt;/p&gt;

&lt;p&gt;PS: 本质就是想实现像 Github: &lt;a href="https://github.com/rails/rails" rel="nofollow" target="_blank"&gt;https://github.com/rails/rails&lt;/a&gt; 这样子的 URL.&lt;/p&gt;</description>
      <author>hynmath</author>
      <pubDate>Wed, 08 Oct 2014 16:31:48 +0800</pubDate>
      <link>https://ruby-china.org/topics/21923</link>
      <guid>https://ruby-china.org/topics/21923</guid>
    </item>
  </channel>
</rss>
