<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>lmm19891114 (jackmin)</title>
    <link>https://ruby-china.org/lmm19891114</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>我用的是 rolify 的一个 gem 包，我在更新用户角色的时候，用户的角色居然删除了</title>
      <description>&lt;p&gt;我在做管理员创建用户功能，引入了一个 rolify 的 gem 包，用了第三张表，用户和角色表叫 users_roles 里面有两个字段 user_id 和 role_id
但是在做编辑用户的时候，修改角色，应该修改 user_id 和 role_id 的对应关系，但此时 roles 表的数据也删除了，这是为什么呢？&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vi"&gt;@user.present&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="vi"&gt;@user.roles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'role'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="vi"&gt;@user.remove_role&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vi"&gt;@user.roles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="vi"&gt;@user.add_role&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="s1"&gt;'role'&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;</description>
      <author>lmm19891114</author>
      <pubDate>Mon, 23 Mar 2015 22:19:15 +0800</pubDate>
      <link>https://ruby-china.org/topics/24801</link>
      <guid>https://ruby-china.org/topics/24801</guid>
    </item>
    <item>
      <title>有没有人知道如何用 rails 来验证复选框必须有一个勾选的验证</title>
      <description>&lt;p&gt;有没有人知道如何用 rails 来验证复选框必须有一个勾选的验证（是后端验证哦）&lt;/p&gt;</description>
      <author>lmm19891114</author>
      <pubDate>Sat, 28 Feb 2015 15:42:10 +0800</pubDate>
      <link>https://ruby-china.org/topics/24388</link>
      <guid>https://ruby-china.org/topics/24388</guid>
    </item>
    <item>
      <title>ActionController::ParameterMissing) "param is missing or the value is empty</title>
      <description>&lt;p&gt;有个 ip 访问 报这个问题
ActionController::ParameterMissing) "param is missing or the value is empty&lt;/p&gt;

&lt;p&gt;但我这边一直重现不了这个问题，各路大侠知道不&lt;/p&gt;</description>
      <author>lmm19891114</author>
      <pubDate>Sun, 15 Feb 2015 14:50:54 +0800</pubDate>
      <link>https://ruby-china.org/topics/24278</link>
      <guid>https://ruby-china.org/topics/24278</guid>
    </item>
    <item>
      <title>关于控制器，模型，以及视图的一些问题？</title>
      <description>&lt;p&gt;今天在看 web 开发敏捷之道遇到了一些问题&lt;/p&gt;

&lt;p&gt;比如一个 Product 模型里写了一个 total_price 的方法，在 products/show.html 里是不是不能直接调 total_price() 这个方法？是不是需要在 product_helper 里写 total_price 方法，才能在 view 层里调取&lt;/p&gt;</description>
      <author>lmm19891114</author>
      <pubDate>Sat, 31 Jan 2015 16:25:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/24047</link>
      <guid>https://ruby-china.org/topics/24047</guid>
    </item>
    <item>
      <title>关于 Rails 的冒号</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;Product&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;validates&lt;/span&gt; &lt;span class="ss"&gt;:image_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:format&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;:with&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="sr"&gt;%r{&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt; (gif|jpg|png)$}i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="ss"&gt;:message&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'must be a URL for GIF, JPG or PNG image '&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;上面是 rails 里的一个验证，那个冒号具体是表示什么意思？字符串文本值？或者看做常量？&lt;/p&gt;

&lt;p&gt;因项目需要，开始学习 rails，新手，今后可能会问一些很小白的问题，还望高手们不要见笑&lt;/p&gt;</description>
      <author>lmm19891114</author>
      <pubDate>Sat, 31 Jan 2015 10:33:54 +0800</pubDate>
      <link>https://ruby-china.org/topics/24042</link>
      <guid>https://ruby-china.org/topics/24042</guid>
    </item>
  </channel>
</rss>
