Gem ruby-china 的 topic 为什么不使用 cancan?

xiaoronglv · 2012年10月24日 · 最后由 huacnlee 回复于 2012年10月24日 · 3398 次阅读
<div class="tools pull-right">
  <%= topic_follow_tag(@topic) %>
  <%= likeable_tag(@topic) %>
  <%= topic_favorite_tag(@topic) %>
  <% if owner?(@topic) or admin? %>
    <%= link_to "", edit_topic_path(@topic), :class => "icon small_edit", :title => "修改本帖" %>
    <%= link_to "", topic_path(@topic.id), :method => :delete, 'data-confirm' => t("common.confirm_delete"), :class => "icon small_delete", :title => "删除本帖" %>
  <% end %>
</div>

既然安装了 gem Cancan,上面一段为什么不使用 if can?

实在看不懂,求指点。

<div class="tools pull-right">
  <%= topic_follow_tag(@topic) %>
  <%= likeable_tag(@topic) %>
  <%= topic_favorite_tag(@topic) %>
  <% if can? %>
    <%= link_to "", edit_topic_path(@topic), :class => "icon small_edit", :title => "修改本帖" %>
    <%= link_to "", topic_path(@topic.id), :method => :delete, 'data-confirm' => t("common.confirm_delete"), :class => "icon small_delete", :title => "删除本帖" %>
  <% end %>
</div>

在 Cancan 加入之前,这里的逻辑就已经有了,后面就没有处理 实际上,在提交的时候有用 Cancan 来验证的

需要 登录 后方可回复, 如果你还没有账号请 注册新账号